Documentation
¶
Overview ¶
Package ingress is fuse-proxy: stable public tcp ports in front of guests that dial in over internal/tunnel.
a route is a public port that belongs to an owner (a vm id) and leads to one port inside that owner's guest. the port is the stable thing. which owner it belongs to can change, and that is the whole of what a migrate does here: the new vm adopts the old vm's ports, and the url every client holds keeps working without any of them learning that anything moved.
Index ¶
- func AdminHandler(p *Proxy, cfg AdminConfig) http.Handler
- type AdminConfig
- type Client
- type Config
- type Opener
- type PortSpec
- type Proxy
- func (p *Proxy) Authenticate(owner, token string) bool
- func (p *Proxy) Close()
- func (p *Proxy) Publish(owner, token string, ports []PortSpec, adoptFrom string) ([]Route, error)
- func (p *Proxy) Remove(owner string) (bool, error)
- func (p *Proxy) Routes(owner string) ([]Route, bool)
- func (p *Proxy) Start(t Opener)
- type Route
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AdminHandler ¶
func AdminHandler(p *Proxy, cfg AdminConfig) http.Handler
AdminHandler serves the admin api.
Types ¶
type AdminConfig ¶
type AdminConfig struct {
Token string
// PublicHost is the name or address clients and guests reach this machine
// by. TunnelPort is the udp port guests dial.
PublicHost string
TunnelPort int
ServerCertPEM string
}
AdminConfig is what the admin api needs beyond the proxy itself.
type Client ¶
Client is the orchestrator's end of the admin api.
func (*Client) Lookup ¶
func (c *Client) Lookup(ctx context.Context, owner string) (orchestrator.IngressGrant, error)
Lookup implements orchestrator.IngressProxy.
func (*Client) Publish ¶
func (c *Client) Publish(ctx context.Context, req orchestrator.IngressRequest) (orchestrator.IngressGrant, error)
Publish implements orchestrator.IngressProxy.
type Config ¶
type Config struct {
// StatePath is where owners and routes are persisted. routes have to
// outlive the process: a proxy that came back with different ports would
// have broken every url it exists to keep stable.
StatePath string
// PortMin and PortMax bound the public ports handed out, inclusive.
PortMin, PortMax int
// BindHost is the address public listeners bind, "" for all.
BindHost string
// HoldTimeout is how long a client connection waits for its guest to be
// reachable before it is closed.
HoldTimeout time.Duration
Logger *slog.Logger
}
Config tunes a Proxy.
type Opener ¶
type Opener interface {
Open(ctx context.Context, owner string, port int) (net.Conn, error)
Drop(owner string)
}
Opener is the part of tunnel.Server the proxy uses.
type Proxy ¶
type Proxy struct {
// contains filtered or unexported fields
}
Proxy owns the routes and their listeners.
func (*Proxy) Authenticate ¶
Authenticate is the tunnel server's authenticator.
func (*Proxy) Publish ¶
Publish creates or updates owner so that it has exactly ports, and returns its routes.
a route that already exists under the same name keeps its public port, so publishing again is how a token is rotated without the url moving. with adoptFrom, each name takes the public port of the same name under adoptFrom, and adoptFrom loses it. connections already running to the old guest are left alone: they are streams on the old guest's tunnel and end when it does.