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.3"
Functions ¶
func BrotliDecode ¶
BrotliDecode decodes a []byte from Brotli binary format
func BrotliEncode ¶
BrotliEncode encodes to brotli from byte array.
func ChunkString ¶
func JoinHashString ¶
func RandomHuttese ¶
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 ¶
type AcceptEncoding []ContentEncoding
func (AcceptEncoding) Print ¶
func (ae AcceptEncoding) Print() string
type AcmeHandler ¶
type AcmeHandler struct {
Active map[string]bool
Domains map[string]string
KeyAuths map[string][]byte
}
func NewAcmeHandler ¶
func NewAcmeHandler() *AcmeHandler
func (*AcmeHandler) CleanUp ¶
func (a *AcmeHandler) CleanUp(domain, token, keyAuth string) error
func (*AcmeHandler) Present ¶
func (a *AcmeHandler) Present(domain, token, keyAuth string) error
type AcmeUser ¶
type AcmeUser struct {
Email string
Registration *registration.Resource
// contains filtered or unexported fields
}
func (*AcmeUser) GetPrivateKey ¶
func (u *AcmeUser) GetPrivateKey() crypto.PrivateKey
func (AcmeUser) GetRegistration ¶
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 ¶
type ConnectionWatcher struct {
// contains filtered or unexported fields
}
func (*ConnectionWatcher) AddDwn ¶
func (cw *ConnectionWatcher) AddDwn(c int64)
Add adds c to the number of active connections.
func (*ConnectionWatcher) AddUp ¶
func (cw *ConnectionWatcher) AddUp(c int64)
func (*ConnectionWatcher) DwnCount ¶
func (cw *ConnectionWatcher) DwnCount() uint64
Count returns the number of connections at the time the call.
func (*ConnectionWatcher) DwnMaxCount ¶
func (cw *ConnectionWatcher) DwnMaxCount() uint64
func (*ConnectionWatcher) OnStateChange ¶
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 ¶
func (cw *ConnectionWatcher) SetUp(c uint64)
func (*ConnectionWatcher) UpCount ¶
func (cw *ConnectionWatcher) UpCount() uint64
func (*ConnectionWatcher) UpMaxCount ¶
func (cw *ConnectionWatcher) UpMaxCount() uint64
func (*ConnectionWatcher) UpdateMaxDwn ¶
func (cw *ConnectionWatcher) UpdateMaxDwn(c uint64)
Sets the maximum number of active connections observed
func (*ConnectionWatcher) UpdateMaxUp ¶
func (cw *ConnectionWatcher) UpdateMaxUp(c uint64)
type ContentEncoding ¶
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 ¶
func NewContentEncoding(raw string) ContentEncoding
type DNSNameComponents ¶
type DNSNameComponents WeightedSlugs
func NewDNSNameComponents ¶
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 ¶
type HandlerDelegate struct{}
func (HandlerDelegate) ServeHTTP ¶
func (hd HandlerDelegate) ServeHTTP(w http.ResponseWriter, r *http.Request)
type Jwt ¶
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 ¶
func (jwt *Jwt) Init()
we need this separate because the JSON unmarshaller creates this object without asking us.
func (*Jwt) UnmarshalJSON ¶
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 ¶
type ReloadableCert struct {
Cert *tls.Certificate
Init bool
// contains filtered or unexported fields
}
func (*ReloadableCert) GetCertificateFunc ¶
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 ¶
type RoutePathTypes []string
func NewRoutePathTypes ¶
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 ¶
type StateHandler ¶
func NewStateHandler ¶
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 ¶
type WebsocketTx ¶
type WeightedSlugs ¶
type WeightedSlugs []string
func (WeightedSlugs) Less ¶
func (w WeightedSlugs) Less(w2 WeightedSlugs) bool
