Documentation ¶
Overview ¶
Package harald contains the core logic of harald.
Harald is a great guy. He takes care of forwarding connections and listens to your needs. Get him started with SIGUSR1, stop him with SIGUSR2 and shut him down for good with SIGTERM. Currently only unix-like systems (as determined by the go build constraint `unix`) are supported due to the dependency to the process signals.
Any logging is done through the default logger of log/slog. Consult the documentation for how to configure it.
Index ¶
Constants ¶
const ( KeyForwarder = "forwarder" KeyError = "error" KeySignal = "signal" KeyPid = "pid" KeyBytesWritten = "bytes-written" KeyConnId = "conn-id" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct { Version int `json:"version" yaml:"version" toml:"version"` LogLevel slog.Level `json:"log_level" yaml:"log_level" toml:"log_level"` DialTimeout Duration `json:"dial_timeout" yaml:"dial_timeout" toml:"dial_timeout"` EnableListeners bool `json:"enable_listeners" yaml:"enable_listeners" toml:"enable_listeners"` Rules map[string]ForwardRule `json:"rules" yaml:"rules" toml:"rules"` }
func LoadConfig ¶ added in v0.2.1
type Duration ¶
func (*Duration) UnmarshalText ¶
type ForwardRule ¶
type ForwardRule struct { DialTimeout Duration `json:"dial_timeout" yaml:"dial_timeout" toml:"dial_timeout"` Listen NetConf `json:"listen" yaml:"listen" toml:"listen"` Connect NetConf `json:"connect" yaml:"connect" toml:"connect"` TLS *TLS `json:"tls" yaml:"tls" toml:"tls"` }
func (ForwardRule) NewForwarder ¶ added in v0.2.0
func (r ForwardRule) NewForwarder(name string, defaultDialTimeout time.Duration) (*Forwarder, error)
NewForwarder initialize a new forwarder based on the rule it's called on and the additional parameters passed in.
type Forwarder ¶
type Forwarder struct { ForwardRule // contains filtered or unexported fields }
type Forwarders ¶
type Forwarders []*Forwarder
Forwarders maintains a list of pointers to Forwarder. It holds pointers because each struct may maintain data that can not be copied.
func (Forwarders) Start ¶
func (forwarders Forwarders) Start()
Start all forwarders in the list. Logs errors encountered while starting a forwarder but continues starting the forwarders.
type TLS ¶
type TLS struct { Certificate string `json:"certificate" yaml:"certificate" toml:"certificate"` Key string `json:"key" yaml:"key" toml:"key"` ClientCAs string `json:"client_cas" yaml:"client_cas" toml:"client_cas"` // ApplicationProtocols offered via ALPN in order of preference. See the // IANA registry for a list of options: // https://www.iana.org/assignments/tls-extensiontype-values/tls-extensiontype-values.xhtml#alpn-protocol-ids ApplicationProtocols []string `json:"application_protocols" yaml:"application_protocols" toml:"application_protocols"` // See the go documentation for details: // https://pkg.go.dev/crypto/tls#ClientAuthType ClientAuth tls.ClientAuthType `json:"client_auth" yaml:"client_auth" toml:"client_auth"` }
TLS configuration for the server side.
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
Package haraldtest provides utilities for testing harald.
|
Package haraldtest provides utilities for testing harald. |