Documentation ¶
Overview ¶
Package config provides the forwarding configuration data models used in this application.
Index ¶
- func IsOnionHost(s string) bool
- type Endpoint
- func (e *Endpoint) Alias() string
- func (e *Endpoint) Description(remoteOnions map[string]string) string
- func (e *Endpoint) IsDest() bool
- func (e *Endpoint) IsOnion() bool
- func (e *Endpoint) IsUnix() bool
- func (e *Endpoint) OnionID() (string, bool)
- func (e *Endpoint) Ports() []int
- func (e *Endpoint) Resolve(asOnion bool) error
- func (e *Endpoint) ServiceKey() []byte
- func (e *Endpoint) SetServiceKey(key []byte)
- func (e *Endpoint) SingleAddr() (string, error)
- type EndpointDoc
- type Forward
- type ForwardDoc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsOnionHost ¶
IsOnionHost returns whether the host is a .onion address.
Types ¶
type Endpoint ¶
type Endpoint struct {
// contains filtered or unexported fields
}
Endpoint represents a source or destination endpoint in a forwarding tunnel. The source may be regarded as the "backend" which provides a service being forwarded. The destination may be regarded as the "frontend" where the service is forwarded to, or published for consumption.
func ParseEndpoint ¶
ParseEndpoint returns an Endpoint from the given string representation and whether it is intended to be used as a destination or source in a forward.
func (*Endpoint) Description ¶
Description returns a string description of the endpoint. If the endpoint destination is an onion, a mapping of alias to remote onion ID may be provided, to render the assigned onion address.
func (*Endpoint) IsDest ¶
IsDest returns whether a resolved endpoint is a destination. If it's not a destination, it's a source in a forward.
func (*Endpoint) OnionID ¶
OnionID returns the onion ID (host without the .onion suffix) and whether the host is an onion.
func (*Endpoint) Resolve ¶
Resolve validates the endpoint to ensure it is well-formed. For UNIX socket endpoints, the socket path is validated for existence. For local network TCP socket endpoints, the host is resolved to a network address according to the system's default name resolver.
asOnion is provided to disambiguate an endpoint that does not yet have its host resolved.
Such name resolution is provided here as a convenience -- if it doesn't resolve how you like, or there's a chance it will choose the wrong interface, configure the actual interface you want. The default resolver is generally Good Enough for container use cases, where the networking and routing is handled up the stack in something like compose or k8s. It might be a bit YOLO-networking on a bare metal server with several physical NICs and multiple DNS names. Caveat emp-tor.
func (*Endpoint) ServiceKey ¶
ServiceKey gets the remote endpoint's service key. May be nil.
func (*Endpoint) SetServiceKey ¶
SetServiceKey sets the remote endpoint's service key.
func (*Endpoint) SingleAddr ¶
SingleAddr returns the string representation of the endpoint as a single address in a port or socket forward. Some endpoints do not have such a representation, in which case an error is returned.
type EndpointDoc ¶
type EndpointDoc struct { Host string `json:"host"` Ports []int `json:"ports"` Path string `json:"unix"` Alias string `json:"alias"` }
EndpointDoc defines a JSON representation of an endpoint.
type Forward ¶
type Forward struct {
// contains filtered or unexported fields
}
Forward defines a network forwarding relay from a source endpoint to a destination endpoint.
func ParseForward ¶
ParseForward returns a new Forward parsed from a string representation
func (*Forward) Description ¶
Description returns a string description of the forward. If the forward destination is an onion, a mapping of alias to remote onion ID may be provided, to render the assigned onion address.
func (*Forward) Destination ¶
Destination returns the destination endpoint in the forwarding relay.
func (*Forward) IsImport ¶
IsImport returns whether the forward is importing an onion to a local network endpoint.
type ForwardDoc ¶
type ForwardDoc struct { Src EndpointDoc `json:"src"` Dest EndpointDoc `json:"dest"` }
ForwardDoc defines a JSON representation of a forward.
func (*ForwardDoc) Forward ¶
func (d *ForwardDoc) Forward() (*Forward, error)
Forward returns a validated and resolved Forward from a JSON document object model.