server

package
v0.0.0-...-627ae92 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 1, 2024 License: MIT Imports: 59 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SYMBOLS characters used for short-urls
	SYMBOLS = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
)

Variables

This section is empty.

Functions

func LoveHandler

func LoveHandler(h http.Handler) http.HandlerFunc

LoveHandler Create a log handler for every request it receives.

func NewEncryptWrapperReader

func NewEncryptWrapperReader(plaintext io.Reader, armored, encrypt io.WriteCloser, buffer io.ReadWriter) io.ReadCloser

func WrapIPFilter

func WrapIPFilter(next http.Handler, opts *IPFilterOptions) http.Handler

WrapIPFilter is equivalent to newIPFilter(opts) then Wrap(next)

Types

type IPFilterOptions

type IPFilterOptions struct {
	//explicity allowed IPs
	AllowedIPs []string
	//explicity blocked IPs
	BlockedIPs []string
	//block by default (defaults to allow)
	BlockByDefault bool
	// TrustProxy enable check request IP from proxy
	TrustProxy bool

	Logger interface {
		Printf(format string, v ...interface{})
	}
}

IPFilterOptions for ipFilter. Allowed takes precedence over Blocked. IPs can be IPv4 or IPv6 and can optionally contain subnet masks (/24). Note however, determining if a given IP is included in a subnet requires a linear scan so is less performant than looking up single IPs.

This could be improved with some algorithmic magic.

type OptionFn

type OptionFn func(*Server)

OptionFn is the option function type

func ClamavHost

func ClamavHost(s string) OptionFn

ClamavHost sets clamav host

func CorsDomains

func CorsDomains(s string) OptionFn

CorsDomains sets CORS domains

func EmailContact

func EmailContact(emailContact string) OptionFn

EmailContact sets email contact

func EnableProfiler

func EnableProfiler() OptionFn

EnableProfiler sets enable profiler

func FilterOptions

func FilterOptions(options IPFilterOptions) OptionFn

FilterOptions sets ip filtering

func ForceHTTPS

func ForceHTTPS() OptionFn

ForceHTTPS sets forcing https

func GoogleAnalytics

func GoogleAnalytics(gaKey string) OptionFn

GoogleAnalytics sets GA key

func HTTPAUTHFilterOptions

func HTTPAUTHFilterOptions(options IPFilterOptions) OptionFn

HTTPAUTHFilterOptions sets basic http auth ips whitelist

func HTTPAuthCredentials

func HTTPAuthCredentials(user string, pass string) OptionFn

HTTPAuthCredentials sets basic http auth credentials

func HTTPAuthHtpasswd

func HTTPAuthHtpasswd(htpasswdPath string) OptionFn

HTTPAuthHtpasswd sets basic http auth htpasswd file

func Listener

func Listener(s string) OptionFn

Listener set listener

func LogFile

func LogFile(logger *log.Logger, s string) OptionFn

LogFile sets log file

func Logger

func Logger(logger *log.Logger) OptionFn

Logger sets logger

func MaxUploadSize

func MaxUploadSize(kbytes int64) OptionFn

MaxUploadSize sets max upload size

func PerformClamavPrescan

func PerformClamavPrescan(b bool) OptionFn

PerformClamavPrescan enables clamav prescan on upload

func ProfileListener

func ProfileListener(s string) OptionFn

ProfileListener sets profile listener

func ProxyPath

func ProxyPath(s string) OptionFn

ProxyPath sets proxy path

func ProxyPort

func ProxyPort(s string) OptionFn

ProxyPort sets proxy port

func Purge

func Purge(days, interval int) OptionFn

Purge sets purge days and option

func RandomTokenLength

func RandomTokenLength(length int) OptionFn

RandomTokenLength sets random token length

func RateLimit

func RateLimit(requests int) OptionFn

RateLimit set rate limit

func TLSConfig

func TLSConfig(cert, pk string) OptionFn

TLSConfig sets TLS config

func TLSListener

func TLSListener(s string, t bool) OptionFn

TLSListener sets TLS listener and option

func TempPath

func TempPath(s string) OptionFn

TempPath sets temp path

func UseLetsEncrypt

func UseLetsEncrypt(hosts []string) OptionFn

UseLetsEncrypt set letsencrypt usage

func UseStorage

func UseStorage(s storage.Storage) OptionFn

UseStorage set storage to use

func UserVoice

func UserVoice(userVoiceKey string) OptionFn

UserVoice sets UV key

func VirustotalKey

func VirustotalKey(s string) OptionFn

VirustotalKey sets virus total key

func WebPath

func WebPath(s string) OptionFn

WebPath sets web path

type Server

type Server struct {
	VirusTotalKey    string
	ClamAVDaemonHost string

	TLSListenerOnly bool

	CorsDomains           string
	ListenerString        string
	TLSListenerString     string
	ProfileListenerString string

	Certificate string

	LetsEncryptCache string
	// contains filtered or unexported fields
}

Server is the main application

func New

func New(options ...OptionFn) (*Server, error)

New is the factory fot Server

func (*Server) RedirectHandler

func (s *Server) RedirectHandler(h http.Handler) http.HandlerFunc

RedirectHandler handles redirect

func (*Server) Run

func (s *Server) Run()

Run starts Server

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL