server

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2023 License: MIT Imports: 55 Imported by: 6

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 added in v1.5.0

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

func WrapIPFilter added in v1.1.0

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

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

Types

type IPFilterOptions added in v1.1.0

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 added in v1.1.7

func CorsDomains(s string) OptionFn

CorsDomains sets CORS domains

func EmailContact added in v1.3.1

func EmailContact(emailContact string) OptionFn

EmailContact sets email contact

func EnableProfiler

func EnableProfiler() OptionFn

EnableProfiler sets enable profiler

func FilterOptions added in v1.1.0

func FilterOptions(options IPFilterOptions) OptionFn

FilterOptions sets ip filtering

func ForceHTTPS added in v1.3.1

func ForceHTTPS() OptionFn

ForceHTTPS sets forcing https

func GoogleAnalytics

func GoogleAnalytics(gaKey string) OptionFn

GoogleAnalytics sets GA key

func HTTPAUTHFilterOptions added in v1.6.0

func HTTPAUTHFilterOptions(options IPFilterOptions) OptionFn

HTTPAUTHFilterOptions sets basic http auth ips whitelist

func HTTPAuthCredentials added in v1.3.1

func HTTPAuthCredentials(user string, pass string) OptionFn

HTTPAuthCredentials sets basic http auth credentials

func HTTPAuthHtpasswd added in v1.6.0

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 added in v1.2.0

func MaxUploadSize(kbytes int64) OptionFn

MaxUploadSize sets max upload size

func PerformClamavPrescan added in v1.4.0

func PerformClamavPrescan(b bool) OptionFn

PerformClamavPrescan enables clamav prescan on upload

func ProfileListener

func ProfileListener(s string) OptionFn

ProfileListener sets profile listener

func ProxyPath added in v1.1.0

func ProxyPath(s string) OptionFn

ProxyPath sets proxy path

func ProxyPort added in v1.2.0

func ProxyPort(s string) OptionFn

ProxyPort sets proxy port

func Purge added in v1.2.0

func Purge(days, interval int) OptionFn

Purge sets purge days and option

func RandomTokenLength added in v1.2.4

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