Documentation ¶
Index ¶
- Constants
- Variables
- func BootStrap()
- func BrotliDecode(input []byte) *[]byte
- func BrotliEncode(input []byte) *[]byte
- func ChunkString(s string, chunkSize int) []string
- func Gunzip(input []byte) *[]byte
- func Gzip(input []byte) *[]byte
- func JoinHashString(hash []byte) string
- func RandomHuttese() string
- func ShutDown()
- func Validate()
- type AboutResponse
- type AcceptEncoding
- type Acme
- type AcmeHandler
- type AcmeUser
- type Atmpt
- type Config
- type Connection
- type ConnectionWatcher
- func (cw *ConnectionWatcher) AddDwn(c int64)
- func (cw *ConnectionWatcher) AddUp(c int64)
- func (cw *ConnectionWatcher) DwnCount() uint64
- func (cw *ConnectionWatcher) DwnMaxCount() uint64
- func (cw *ConnectionWatcher) OnStateChange(conn net.Conn, state http.ConnState)
- func (cw *ConnectionWatcher) SetUp(c uint64)
- func (cw *ConnectionWatcher) UpCount() uint64
- func (cw *ConnectionWatcher) UpMaxCount() uint64
- func (cw *ConnectionWatcher) UpdateMaxDwn(c uint64)
- func (cw *ConnectionWatcher) UpdateMaxUp(c uint64)
- type ContentEncoding
- type DNSNameComponents
- type Down
- type Downstream
- type HTTPClient
- type HandlerDelegate
- type Http
- type Jwt
- type KeySet
- type KidPair
- type LabelWeight
- type PDuration
- type Policy
- type Proxy
- type ReloadableCert
- type ResourceMapping
- type Resp
- type Route
- type RoutePath
- type RoutePathTypes
- type Routes
- type Runtime
- type State
- type StateHandler
- type StatusCodeResponse
- type TLSType
- type Tls
- type TlsLink
- type URL
- type Up
- type Upstream
- type WebsocketStatus
- type WebsocketTx
- type WeightedSlugs
Constants ¶
const AcceptEncodingS = "Accept-Encoding"
const COMMA = ","
const Days30 = time.Duration(time.Hour * 24 * 30)
const Days398 = PDuration(time.Hour * 24 * 398)
const DefaultConfigFile = "j8acfg.yml"
const EOF = "EOF"
const HTTP = "HTTP"
const HTTP11 = "1.1"
const HTTPS = "https://"
const J8ACFG_YML = "J8ACFG_YML"
const Q = "?"
const STAR = "*"
const Server string = "Server"
Version is the server version
const TLS = "TLS"
const UpgradeHeader = "Upgrade"
const XRequestID = "X-Request-Id"
XRequestID is a per HTTP request unique identifier
Variables ¶
var CompressedContentEncodings = AcceptEncoding{EncBrotli, EncGzip, EncXGzip, EncDeflate, EncXDeflate, EncCompress, EncXCompress}
var ConfigFile = ""
var GzipContentEncodings = AcceptEncoding{EncGzip, EncXGzip}
var ID string = "unknown"
ID is a unique server ID
var SupportedContentEncodings = AcceptEncoding{EncStar, EncIdentity, EncBrotli, EncGzip, EncXGzip}
var UnsupportedContentEncodings = AcceptEncoding{EncDeflate, EncXDeflate, EncCompress, EncXCompress}
var Version string = "v1.1.1"
Functions ¶
func BrotliDecode ¶ added in v0.9.1
BrotliDecode decodes a []byte from Brotli binary format
func BrotliEncode ¶ added in v0.9.1
BrotliEncode encodes to brotli from byte array.
func ChunkString ¶ added in v0.9.0
func JoinHashString ¶ added in v0.9.0
func RandomHuttese ¶ added in v1.0.1
func RandomHuttese() string
Types ¶
type AboutResponse ¶
AboutResponse exposes standard environment
func (AboutResponse) AsJSON ¶
func (aboutResponse AboutResponse) AsJSON() []byte
AsJSON renders the status Code response into a JSON string as []byte
func (AboutResponse) AsString ¶
func (aboutResponse AboutResponse) AsString() string
type AcceptEncoding ¶ added in v0.9.1
type AcceptEncoding []ContentEncoding
func (AcceptEncoding) Print ¶ added in v0.9.1
func (ae AcceptEncoding) Print() string
type AcmeHandler ¶ added in v0.9.0
type AcmeHandler struct { Active map[string]bool Domains map[string]string KeyAuths map[string][]byte }
func NewAcmeHandler ¶ added in v0.9.0
func NewAcmeHandler() *AcmeHandler
func (*AcmeHandler) CleanUp ¶ added in v0.9.0
func (a *AcmeHandler) CleanUp(domain, token, keyAuth string) error
func (*AcmeHandler) Present ¶ added in v0.9.0
func (a *AcmeHandler) Present(domain, token, keyAuth string) error
type AcmeUser ¶ added in v0.9.0
type AcmeUser struct { Email string Registration *registration.Resource // contains filtered or unexported fields }
func (*AcmeUser) GetPrivateKey ¶ added in v0.9.0
func (u *AcmeUser) GetPrivateKey() crypto.PrivateKey
func (AcmeUser) GetRegistration ¶ added in v0.9.0
func (u AcmeUser) GetRegistration() *registration.Resource
type Atmpt ¶
type Atmpt struct { URL *URL Label string Count int StatusCode int ContentEncoding ContentEncoding CompleteHeader chan struct{} CompleteBody chan struct{} Aborted <-chan struct{} AbortedFlag bool CancelFunc func() // contains filtered or unexported fields }
Atmpt wraps connection attempts to specific upstreams that are already mapped by label
type Config ¶
type Config struct { Policies map[string]Policy Routes Routes Jwt map[string]*Jwt Resources map[string][]ResourceMapping Connection Connection DisableXRequestInfo bool TimeZone string LogLevel string }
Config is the system wide configuration for j8a
type Connection ¶
type Connection struct { Downstream Downstream Upstream Upstream }
Connection Params
type ConnectionWatcher ¶ added in v0.9.3
type ConnectionWatcher struct {
// contains filtered or unexported fields
}
func (*ConnectionWatcher) AddDwn ¶ added in v0.9.3
func (cw *ConnectionWatcher) AddDwn(c int64)
Add adds c to the number of active connections.
func (*ConnectionWatcher) AddUp ¶ added in v0.9.3
func (cw *ConnectionWatcher) AddUp(c int64)
func (*ConnectionWatcher) DwnCount ¶ added in v0.9.3
func (cw *ConnectionWatcher) DwnCount() uint64
Count returns the number of connections at the time the call.
func (*ConnectionWatcher) DwnMaxCount ¶ added in v0.9.3
func (cw *ConnectionWatcher) DwnMaxCount() uint64
func (*ConnectionWatcher) OnStateChange ¶ added in v0.9.3
func (cw *ConnectionWatcher) OnStateChange(conn net.Conn, state http.ConnState)
OnStateChange records open connections in response to connection state changes. Set net/http Server.ConnState to this method as value.
func (*ConnectionWatcher) SetUp ¶ added in v0.9.3
func (cw *ConnectionWatcher) SetUp(c uint64)
func (*ConnectionWatcher) UpCount ¶ added in v0.9.3
func (cw *ConnectionWatcher) UpCount() uint64
func (*ConnectionWatcher) UpMaxCount ¶ added in v0.9.3
func (cw *ConnectionWatcher) UpMaxCount() uint64
func (*ConnectionWatcher) UpdateMaxDwn ¶ added in v0.9.3
func (cw *ConnectionWatcher) UpdateMaxDwn(c uint64)
Sets the maximum number of active connections observed
func (*ConnectionWatcher) UpdateMaxUp ¶ added in v0.9.3
func (cw *ConnectionWatcher) UpdateMaxUp(c uint64)
type ContentEncoding ¶ added in v0.9.1
type ContentEncoding string
const ( EncStar ContentEncoding = "*" EncIdentity ContentEncoding = "identity" EncBrotli ContentEncoding = "br" EncGzip ContentEncoding = "gzip" EncXGzip ContentEncoding = "x-gzip" EncDeflate ContentEncoding = "deflate" EncXDeflate ContentEncoding = "x-deflate" EncCompress ContentEncoding = "compress" EncXCompress ContentEncoding = "x-compress" )
func NewContentEncoding ¶ added in v0.9.1
func NewContentEncoding(raw string) ContentEncoding
type DNSNameComponents ¶ added in v1.0.0
type DNSNameComponents WeightedSlugs
func NewDNSNameComponents ¶ added in v1.0.0
func NewDNSNameComponents(r Route) DNSNameComponents
type Down ¶
type Down struct { Req *http.Request Resp Resp Method string Host string Path string URI string UserAgent string AcceptEncoding AcceptEncoding Body []byte Aborted <-chan struct{} AbortedFlag bool Timeout <-chan struct{} TimeoutFlag bool ReqTooLarge bool HttpVer string TlsVer string Port int Listener string // contains filtered or unexported fields }
Down wraps downstream exchange
type Downstream ¶
type Downstream struct { // ReadTimeoutSeconds is the maximum duration for reading the entire // request, including the body, the downstream user agent sends to us. ReadTimeoutSeconds int // WriteTimeoutSeconds is the maximum duration round trip time in seconds any // single request spends in the server, this includes the time to read the request, // processing upstream attempts and writing the response into downstream socket. RoundTripTimeoutSeconds int // IdleTimeoutSeconds is the maximum duration, a downstream idle socket connection is kept open // before the server hangs up on the downstream user agent. IdleTimeoutSeconds int // MaxBodyBytes is the maximum size of the incoming HTTP request body before it is rejected MaxBodyBytes int64 // Http block. defaults to on Http Http // Tls block defaults to off Tls Tls }
Downstream params for the HTTP or TLS server that j8a exposes
type HTTPClient ¶
type HandlerDelegate ¶ added in v0.8.0
type HandlerDelegate struct{}
func (HandlerDelegate) ServeHTTP ¶ added in v0.8.0
func (hd HandlerDelegate) ServeHTTP(w http.ResponseWriter, r *http.Request)
type Jwt ¶ added in v0.7.0
type Jwt struct { Name string Alg string // Jwt key supports pem encoding for public keys, certificates unencoded secrets for hmac. Key string // JwksUrl loads remotely. JwksUrl string RSAPublic KeySet ECDSAPublic KeySet Secret KeySet AcceptableSkewSeconds string Claims []string // contains filtered or unexported fields }
func (*Jwt) Init ¶ added in v0.7.1
func (jwt *Jwt) Init()
we need this separate because the JSON unmarshaller creates this object without asking us.
func (*Jwt) LoadJwks ¶ added in v0.7.0
TODO this method needs a refactor and has high cognitive complexity
func (*Jwt) UnmarshalJSON ¶ added in v1.1.0
type LabelWeight ¶
LabelWeight describes routing to labels
type PDuration ¶
func (PDuration) AsDuration ¶
type Proxy ¶
Proxy wraps data for a single downstream request/response with multiple upstream HTTP request/response cycles.
type ReloadableCert ¶ added in v0.9.0
type ReloadableCert struct { Cert *tls.Certificate Init bool // contains filtered or unexported fields }
func (*ReloadableCert) GetCertificateFunc ¶ added in v0.9.0
func (r *ReloadableCert) GetCertificateFunc(clientHello *tls.ClientHelloInfo) (*tls.Certificate, error)
type ResourceMapping ¶
ResourceMapping describes upstream servers
type Resp ¶
type Resp struct { Writer http.ResponseWriter StatusCode int Message string Body *[]byte ContentLength int64 ContentEncoding ContentEncoding }
Resp wraps downstream http response writer and data
type Route ¶
type Route struct { Host string //idna host pattern PunyHost string //punycode host pattern CompiledPunyHost *regexp.Regexp // as regex Path string PathType string // exact | prefix CompiledPathRegex *regexp.Regexp Transform string Resource string Policy string Jwt string }
Route maps a Path to an upstream resource
type RoutePathTypes ¶ added in v1.0.0
type RoutePathTypes []string
func NewRoutePathTypes ¶ added in v1.0.0
func NewRoutePathTypes() RoutePathTypes
type Runtime ¶
type Runtime struct { Config Start time.Time StateHandler *StateHandler Memory []sample AcmeHandler *AcmeHandler ReloadableCert *ReloadableCert ConnectionWatcher ConnectionWatcher // contains filtered or unexported fields }
Runtime struct defines runtime environment wrapper for a config.
var Runner *Runtime
Runner is the Live environment of the server
func (*Runtime) CountUpConns ¶ added in v0.9.3
func (*Runtime) FindUpConns ¶ added in v0.9.3
type StateHandler ¶ added in v1.1.0
func NewStateHandler ¶ added in v1.1.0
func NewStateHandler() *StateHandler
type StatusCodeResponse ¶
type StatusCodeResponse struct { AboutResponse Code int Message string }
StatusCodeResponse defines a JSON structure for a canned HTTP response
func (StatusCodeResponse) AsJSON ¶
func (statusCodeResponse StatusCodeResponse) AsJSON() []byte
AsJSON renders the status Code response into a JSON string as []byte
func (StatusCodeResponse) AsString ¶
func (statusCodeResponse StatusCodeResponse) AsString() string
type Upstream ¶
type Upstream struct { // PoolSize is the maximum size of the client socket connection pool for idle connections PoolSize int // IdleTimeoutSeconds is the total wait period in seconds before we hang up on an idle upstream connection. IdleTimeoutSeconds int // SocketTimeoutSeconds is the wait period to establish socket connection with an upstream server. // This setting controls roundtrip time for establishing simple TCP connections, combined with handshake time for TLS // if applicable. SocketTimeoutSeconds int // ReadTimeoutSeconds is the wait period to read the entire upstream response once connection was established // before an individual upstream request is aborted ReadTimeoutSeconds int // MaxAttempts is the maximum allowable number of request attempts to obtain a successful response for repeatable // HTTP requests. MaxAttempts int // TlsInsecureSkipVerify skips the host name validation and certificate chain verification of upstream connections // using TLS. Use this only for testing or if you know what you are doing. Defaults to false TlsInsecureSkipVerify bool }
Upstream connection params for remote servers that are being proxied
type WebsocketStatus ¶ added in v0.8.0
type WebsocketTx ¶ added in v0.8.0
type WeightedSlugs ¶ added in v1.0.0
type WeightedSlugs []string
func (WeightedSlugs) Less ¶ added in v1.0.0
func (w WeightedSlugs) Less(w2 WeightedSlugs) bool
Source Files ¶
- abouthandler.go
- acmehandler.go
- brotli.go
- config.go
- connection.go
- connectionwatcher.go
- globaloptionshandler.go
- gzip.go
- httpclient.go
- iprex.go
- jwt.go
- logger.go
- policy.go
- proxy.go
- proxyhandler.go
- redirecthandler.go
- reloadablecert.go
- resource.go
- route.go
- server.go
- state.go
- stats.go
- tls.go
- upstream.go
- websockethandler.go