Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( OffloadBackoff = 100 * time.Millisecond OffloadAttempts = 5 )
OffloadBackoff and OffloadAttempts pace Offload on a leg tunnelled through TURN-UDP: the TURN client assigns the channel towards the peer at the first write and binds it a round trip later.
var ErrNotOffloadable = errors.New("not offloadable")
ErrNotOffloadable is the error of Offload on an entry the kernel cannot carry.
Functions ¶
Types ¶
type Conntrack ¶
type Conntrack struct {
// contains filtered or unexported fields
}
Conntrack tracks the client conns of a server, keyed by their 5-tuple, each with an idle timer. Close closes every entry it ever tracked and refuses new ones.
func NewConntrack ¶
NewConntrack creates a conntrack whose entries time out after idle.
func (*Conntrack) Add ¶
Add tracks an entry under its client's key and arms its idle timer, replacing a stale entry of the same key; false if the conntrack is closed, and the caller keeps the conns.
func (*Conntrack) Close ¶
func (t *Conntrack) Close()
Close closes every entry and refuses new ones.
type Entry ¶
type Entry struct {
Client api.Conn
// Leg is the conn the client conn is relayed to: set before Add for a forwarded entry, by
// SetLeg later for an entry the server relays itself; nil for a conn a server hands on, like
// TURN.
Leg api.Conn
Hooks EntryHooks
// contains filtered or unexported fields
}
Entry is a tracked client conn and, when forwarded or offloaded, its leg.
func (*Entry) Disarm ¶
func (e *Entry) Disarm()
Disarm stops the idle timer for good: something else owns the entry's lifetime from now on.
func (*Entry) LastActive ¶
LastActive returns the time of the entry's last activity, in user space or, for an offloaded entry, in the kernel: the kernel's traffic since the last call counts as activity now.
func (*Entry) Offload ¶
Offload hands the entry's datagrams to the kernel engine, both directions: a packet from the client goes out on the leg's wire and back, the packets matching the punt rules excepted. It takes a UDP client conn and a UDP or TURN-UDP leg, the latter once its channel towards the peer is bound, which Offload waits for, so it may block for a few seconds. Anything else, and a refusal of the engine (such as the offload limit), leaves the entry in user space. Offloading an offloaded entry again replaces its offload, for a leg that changed. An offloaded entry's idle check counts the kernel's traffic too, and closing the entry removes it from the engine.
type EntryHooks ¶
type EntryHooks struct {
// OnError is called by the forwarder on a failed write, before the entry closes.
OnError func(msg string)
// OnClose is called once, when the entry closes, before its conns close.
OnClose func(reason string)
}
EntryHooks are a server's callbacks on one entry.