Documentation ¶
Index ¶
- Variables
- func NewAliasHandler(pathMap string, docRoot string, ...) fasthttp.RequestHandler
- type BackendList
- type DataCache
- func (dc *DataCache) DataCacheGetKVHandler() fasthttp.RequestHandler
- func (dc *DataCache) DataCacheJSONHandler() fasthttp.RequestHandler
- func (dc *DataCache) DataCacheListKVHandler() fasthttp.RequestHandler
- func (dc *DataCache) DataCacheSetKVHandler() fasthttp.RequestHandler
- func (dc *DataCache) DataCacheSetProxyHandler() fasthttp.RequestHandler
- func (dc *DataCache) GetUIDByToken(tk string) (uid uint64, ok bool)
- func (dc *DataCache) GetValue(uid uint64, key string) (value string, ok bool)
- func (dc *DataCache) JSONContentHandler() fasthttp.RequestHandler
- func (dc *DataCache) MergeTokens(tokens map[string]uint64, overwrite bool) (replaced map[string]uint64)
- func (dc *DataCache) ProxyAuthHandler() multiproxy.ProxyAuthHandler
- func (dc *DataCache) SaveToDir(cacheDir string) (err error)
- func (dc *DataCache) SetKeyValue(uid uint64, key, value string)
- func (dc *DataCache) SetToken(tk string, uid uint64)
- type HostStat
- type PathMapEntry
- type ServerImp
- func (h *ServerImp) DomainACL(name string) error
- func (h *ServerImp) DomainACLNoIP(name string) error
- func (h *ServerImp) FastHTTPChallengeHandler(am *certmagic.ACMEManager, next fasthttp.RequestHandler) fasthttp.RequestHandler
- func (h *ServerImp) MagicServerImp(redirect, next fasthttp.RequestHandler) fasthttp.RequestHandler
- func (h *ServerImp) MatchHostHandler(name string) fasthttp.RequestHandler
- func (h *ServerImp) PrefixRedirectHandler(next fasthttp.RequestHandler) fasthttp.RequestHandler
- func (h *ServerImp) PrefixTLSRedirectHandler() fasthttp.RequestHandler
- func (h *ServerImp) RedirectToTLSHandler() fasthttp.RequestHandler
- func (h *ServerImp) ServerControlHandler(ctx *fasthttp.RequestCtx)
- func (h *ServerImp) ServerHandler(next fasthttp.RequestHandler) fasthttp.RequestHandler
- func (h *ServerImp) ServerHostSwitchHandler(next fasthttp.RequestHandler) fasthttp.RequestHandler
Constants ¶
This section is empty.
Variables ¶
var ( // HTTPContentType is HTTP Content-Type header key HTTPContentType = []byte("Content-Type") // ApplicationJSON is HTTP Content-Type header value ApplicationJSON = []byte("application/json") )
Functions ¶
func NewAliasHandler ¶
func NewAliasHandler(pathMap string, docRoot string, vhost, generateIndexPages, compress, byteRange bool, pathNotFound fasthttp.RequestHandler) fasthttp.RequestHandler
NewAliasHandler return a RequestHandler which will handle file access
Types ¶
type BackendList ¶
type BackendList struct {
// contains filtered or unexported fields
}
BackendList for reverse proxy <*|*.example.com|example.com>@10.0.0.2:9080:tls/be1.example.com:9080^iphash, target@backendlist^load‑balancing methods,[more target section], tls mark in backend list means connect to backend by tls
func NewBackendList ¶
func NewBackendList() *BackendList
NewBackendList return an initialed *backendList
func NewBackendListFromArgs ¶
func NewBackendListFromArgs(backendArgs string) *BackendList
NewBackendListFromArgs parse input args and return *backendList
func (*BackendList) AddBackendArgs ¶
func (be *BackendList) AddBackendArgs(backendArgs string) error
AddBackendArgs add more backend to backendList
type DataCache ¶
type DataCache struct {
// contains filtered or unexported fields
}
DataCache implements internal data/cache management
func LoadDataCache ¶
LoadDataCache load DataCache from saved fastcache dir, or create new on fatal. size counted in bytes.
func (*DataCache) DataCacheGetKVHandler ¶
func (dc *DataCache) DataCacheGetKVHandler() fasthttp.RequestHandler
DataCacheGetKVHandler return a fasthttp.RequestHandler which can update dataCache by token/key/value, tlsRouter.GET("/api/db/set/:token/:key/:value", dc.DataCacheGetKVHandler())
func (*DataCache) DataCacheJSONHandler ¶
func (dc *DataCache) DataCacheJSONHandler() fasthttp.RequestHandler
DataCacheJSONHandler return a fasthttp.RequestHandler which can update dataCache by token/key/JSON
func (*DataCache) DataCacheListKVHandler ¶
func (dc *DataCache) DataCacheListKVHandler() fasthttp.RequestHandler
DataCacheListKVHandler return a fasthttp.RequestHandler which can list dataCache by token/key in JSON text, tlsRouter.GET("/api/db/list/:token/:key", dc.DataCacheListKVHandler())
func (*DataCache) DataCacheSetKVHandler ¶
func (dc *DataCache) DataCacheSetKVHandler() fasthttp.RequestHandler
DataCacheSetKVHandler return a fasthttp.RequestHandler which can update dataCache by token/key/value, tlsRouter.GET("/api/db/set/:token/:key/:value", dc.DataCacheSetKVHandler())
func (*DataCache) DataCacheSetProxyHandler ¶
func (dc *DataCache) DataCacheSetProxyHandler() fasthttp.RequestHandler
DataCacheSetProxyHandler return a fasthttp.RequestHandler which can update proxy setting by token/key/value, tlsRouter.GET("/api/db/setproxy/:token/:key/:value", dc.DataCacheSetKVHandler())
func (*DataCache) GetUIDByToken ¶
GetUIDByToken get uid from tokens, return ok == true when hit
func (*DataCache) JSONContentHandler ¶
func (dc *DataCache) JSONContentHandler() fasthttp.RequestHandler
JSONContentHandler return a fasthttp.RequestHandler which show current contents to client in JSON
func (*DataCache) MergeTokens ¶
func (dc *DataCache) MergeTokens(tokens map[string]uint64, overwrite bool) (replaced map[string]uint64)
MergeTokens DataCache with input token list, duplicated tokens will be ignored if overwrite flag is false. return replaced tokens
func (*DataCache) ProxyAuthHandler ¶
func (dc *DataCache) ProxyAuthHandler() multiproxy.ProxyAuthHandler
ProxyAuthHandler return a fasthttp.RequestHandler which can update proxy setting by token/key/value, tlsRouter.GET("/api/db/setproxy/:token/:key/:value", dc.DataCacheSetKVHandler())
func (*DataCache) SaveToDir ¶
SaveToDir flush current DataCache data into disk cacheDir, if cacheDir is empty, will save to the dir which used on loading.
func (*DataCache) SetKeyValue ¶
SetKeyValue set uid,key,value into contents
type PathMapEntry ¶
PathMapEntry record a path to URL mapping
type ServerImp ¶
type ServerImp struct { LastURI string Counter int64 CtrlToken []byte NormalHostSwitch map[string]fasthttp.RequestHandler WildcardHostSwitch map[string]fasthttp.RequestHandler Domains []string WildcardDomains []string DefaultServerName string TrimList [][]byte Backends *BackendList // contains filtered or unexported fields }
ServerImp redirect HTTP requests to HTTPS
func (*ServerImp) DomainACLNoIP ¶
DomainACLNoIP do ACL on access host, IP not allowed
func (*ServerImp) FastHTTPChallengeHandler ¶
func (h *ServerImp) FastHTTPChallengeHandler(am *certmagic.ACMEManager, next fasthttp.RequestHandler) fasthttp.RequestHandler
FastHTTPChallengeHandler return a fasthttp.RequestHandler which use for handle ACME HTTP challenge, only requests to "/.well-known/acme-challenge/" should be route to this handler.
func (*ServerImp) MagicServerImp ¶
func (h *ServerImp) MagicServerImp(redirect, next fasthttp.RequestHandler) fasthttp.RequestHandler
MagicServerImp return a fasthttp.RequestHandler which call redirect handler and return on redirected, otherwise call next
func (*ServerImp) MatchHostHandler ¶
func (h *ServerImp) MatchHostHandler(name string) fasthttp.RequestHandler
MatchHostHandler do handler matching on access host, will return nil for mismatch.
func (*ServerImp) PrefixRedirectHandler ¶
func (h *ServerImp) PrefixRedirectHandler(next fasthttp.RequestHandler) fasthttp.RequestHandler
PrefixRedirectHandler return a fasthttp.RequestHandler which trim the prefix from request host and redirect to new host, if prefix not found, will pass request to next handler.
func (*ServerImp) PrefixTLSRedirectHandler ¶
func (h *ServerImp) PrefixTLSRedirectHandler() fasthttp.RequestHandler
PrefixTLSRedirectHandler return a fasthttp.RequestHandler which redirect a http request to https, and trim the prefix from request host and redirect to new host, if prefix not found, will pass request to next handler.
func (*ServerImp) RedirectToTLSHandler ¶
func (h *ServerImp) RedirectToTLSHandler() fasthttp.RequestHandler
RedirectToTLSHandler return a fasthttp.RequestHandler which redirect a http request to https
func (*ServerImp) ServerControlHandler ¶
func (h *ServerImp) ServerControlHandler(ctx *fasthttp.RequestCtx)
ServerControlHandler process shutdown command from remote
func (*ServerImp) ServerHandler ¶
func (h *ServerImp) ServerHandler(next fasthttp.RequestHandler) fasthttp.RequestHandler
ServerHandler return a fasthttp.RequestHandler which redirect a http request to https
func (*ServerImp) ServerHostSwitchHandler ¶
func (h *ServerImp) ServerHostSwitchHandler(next fasthttp.RequestHandler) fasthttp.RequestHandler
ServerHostSwitchHandler return a fasthttp.RequestHandler which select handler by request host