Documentation
¶
Overview ¶
Package api holds the contracts between the dataplane objects, which refer to each other by name.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNotSupported = errors.New("not supported")
ErrNotSupported is returned for a request a Dialer cannot serve.
Functions ¶
This section is empty.
Types ¶
type Conn ¶
type Conn interface {
net.Conn
Tag() Tag
// TransportAddrs returns the local and remote addresses of the transport on the wire.
TransportAddrs() (local, remote net.Addr)
// Channel returns the TURN channel the traffic towards peer is framed with, if any.
Channel(peer net.Addr) (uint16, bool)
}
Conn is a connected transport with its tag and the wire facts the offload engine needs.
type Dialer ¶
type Dialer interface {
Named
Start() error
Close(shutdown bool) error
// Protocol is the network the peers are reached over.
Protocol() stnrv2.Protocol
// Tag is the tag of the conns the dialer makes.
Tag() Tag
// Dial connects to addr, from local if not nil.
Dial(ctx context.Context, local net.Addr, addr string) (Conn, error)
// ListenPacket makes a relay socket and returns the address it is advertised at.
ListenPacket(network string, port int) (net.PacketConn, net.Addr, error)
// Listen makes a relayed listener and returns the address it is advertised at.
Listen(network string, port int) (net.Listener, net.Addr, error)
}
Dialer is the transport that reaches the peers of a cluster. What it cannot do fails with ErrNotSupported.
type Filter ¶
Filter admits or drops traffic by the address and port of its client or peer: Match returns the verdict of its first rule matching the address. Set Port to zero to ignore the port rules during Match.
type Router ¶
type Router interface {
Named
// Targets returns the endpoints of the cluster that carry a port, resolved: the destinations
// a server dialing a peer of its own choice chooses from.
Targets() []netip.AddrPort
}
Router lists the destinations of a cluster.
type Server ¶
type Server interface {
Named
Start() error
Close(shutdown bool) error
// Serve takes a conn, and may block until it can. On error the caller keeps the conn.
Serve(c Conn) (Conn, Verdict, error)
// Sessions returns the number of live sessions: TURN allocations or L4 flows.
Sessions() int
}
Server takes client conns.
type Tag ¶
type Tag struct {
Name string
Proto stnrv2.Protocol
Labels map[string]string
// PublicAddr and PublicPort are the public address of the listener, where set.
PublicAddr string
PublicPort int
}
Tag names the listener or cluster that created a conn, and the protocol its packets travel on: the listener's protocol, or for a cluster's conn TLS or DTLS when the cluster secures it and the TURN transport of the tunnel (TURN-UDP, TURN-TCP, TURN-TLS, TURN-DTLS) for a datagram conn through one. Labels are the labels of the listener, nil for none.