Documentation
¶
Index ¶
- Variables
- func CreateDefaultConfig(file, defaultPath string) (bool, error)
- func CreateExampleRoute(file string) error
- type Config
- type ConfigDuration
- type InterfaceTask
- type ListenAddress
- type RedirectData
- type RegexStore
- type Route
- type RouteLocation
- type ServerConfig
- type TLSKeyCertPair
- type TaskData
Constants ¶
This section is empty.
Variables ¶
var ErrAddrNotFound = errors.New("Address not found")
ErrAddrNotFound address not found
var RegexpStore = NewRegexStore()
RegexpStore store regexes
Functions ¶
func CreateDefaultConfig ¶
CreateDefaultConfig creates the default config file
func CreateExampleRoute ¶
CreateExampleRoute creates an example route
Types ¶
type Config ¶
type Config struct { Server ServerConfig `toml:"Server"` ListenAddresses []ListenAddress RouteFiles []string }
Config configuration file
func (Config) GetAddress ¶
func (config Config) GetAddress(sAddress string) *ListenAddress
GetAddress gets address from config
func (Config) GetPreferredSSLAddress ¶
func (config Config) GetPreferredSSLAddress() *ListenAddress
GetPreferredSSLAddress returns preferred SSL address
func (*Config) LoadRoutes ¶
LoadRoutes loads the routes specified in config
type ConfigDuration ¶
ConfigDuration duration for config
func (ConfigDuration) MarshalText ¶
func (d ConfigDuration) MarshalText() ([]byte, error)
MarshalText implements encoding.TextMarshaler
func (*ConfigDuration) UnmarshalText ¶
func (d *ConfigDuration) UnmarshalText(data []byte) error
UnmarshalText implements encoding.TextUnmarshaler
type InterfaceTask ¶
type InterfaceTask string
InterfaceTask task for an Address interface
const ( HTTPRedirectTask InterfaceTask = "httpredirect" ProxyTask InterfaceTask = "proxy" )
...
type ListenAddress ¶
type ListenAddress struct { Address string SSL bool Task InterfaceTask TaskData TaskData IsRedirectInterface bool `toml:"-"` }
ListenAddress config for ports
func (ListenAddress) GetAddress ¶
func (address ListenAddress) GetAddress() string
GetAddress returns address of a listenAddress
func (ListenAddress) GetPort ¶
func (address ListenAddress) GetPort() string
GetPort returns port of address
func (*ListenAddress) GetTask ¶
func (address *ListenAddress) GetTask() InterfaceTask
GetTask gets task from AddressInterface. If not set, return Default task
type RedirectData ¶
RedirectData data for interface Task to redirect
func (RedirectData) GetBody ¶
func (redirectData RedirectData) GetBody() string
GetBody returns body. If empty return default body
func (RedirectData) GetHTTPCode ¶
func (redirectData RedirectData) GetHTTPCode() int
GetHTTPCode returns body. If empty return default body
type RegexStore ¶
RegexStore store compiled regex to improve performance
func (*RegexStore) GetPattern ¶
func (store *RegexStore) GetPattern(pattern string) *regexp.Regexp
GetPattern returns a regexp. If pattern not found, compile and store
type Route ¶
type Route struct { FileName string `toml:"-"` ServerNames []string Interfaces []string ListenAddresses []*ListenAddress `toml:"-"` SSL TLSKeyCertPair Locations []RouteLocation `toml:"Location"` DefaultLocation *RouteLocation `toml:"-"` }
Route a reverseproxy route
func GetRouteForHost ¶
GetRouteForHost returns route by host (servername or route)
func GetRoutesFromAddress ¶
func GetRoutesFromAddress(routes []Route, address ListenAddress) []*Route
GetRoutesFromAddress gets all routes assigned to an address
func (Route) HasAddress ¶
func (route Route) HasAddress(address ListenAddress) bool
HasAddress return true if route has an address
func (*Route) LoadAddress ¶
LoadAddress loads an address from config. Returns false if at least one address was not found
type RouteLocation ¶
type RouteLocation struct { // Toml config attributes Location string Destination string SrcIPHeader string Regex bool // Allow/deny hosts Allow []string Deny string // Non toml attrs DestinationURL *url.URL `toml:"-"` Route *Route `toml:"-"` HasDenyRoule bool `toml:"-"` }
RouteLocation location for route
func FindMatchingLocation ¶
func FindMatchingLocation(routes []*Route, r *http.Request) *RouteLocation
FindMatchingLocation finds location
func (*RouteLocation) Init ¶
func (location *RouteLocation) Init(route *Route)
Init inits a location. Gets called on loading its assigned route
func (RouteLocation) ModifyProxyRequest ¶
func (location RouteLocation) ModifyProxyRequest(req *http.Request)
ModifyProxyRequest modifies a request to a proxy forward request
func (*RouteLocation) Ports ¶
func (location *RouteLocation) Ports() []string
Ports returns a list with ports used by the given RouteLocation
type ServerConfig ¶
type ServerConfig struct { MaxHeaderSize units.Datasize ReadTimeout ConfigDuration WriteTimeout ConfigDuration }
ServerConfig configuration for webserver
type TLSKeyCertPair ¶
TLSKeyCertPair pair of tls key/cert file
func GetTLSCerts ¶
func GetTLSCerts(routes []Route, address *ListenAddress) []TLSKeyCertPair
GetTLSCerts get all required certifitates/keys from routes which are assigned to the given address
func (TLSKeyCertPair) GetCertificate ¶
func (pair TLSKeyCertPair) GetCertificate() (tls.Certificate, error)
GetCertificate gets certificate from TLSKeyCertPair