Documentation
¶
Overview ¶
Package relayfwd carries a relay's port to an exit on another address family, which the kernel's DNAT cannot do: a rule cannot translate an IPv4 packet into an IPv6 one. The agent listens on the port itself instead, dials the exit for every connection (or keeps one session per client address for UDP) and passes the bytes on unchanged — the traffic is encrypted end to end, exactly as with the kernel forward.
The package is the plain L4 half of the bridge in internal/node/bridge: no pairing, no authentication. The entry holds no keys and decrypts nothing; its own load counts the traffic twice, as it does for any relay. It takes traffic from the internet in a process that runs as root, so what one source, one port and the whole node may hold is bounded (Server's limits).
Index ¶
Constants ¶
const ( // DialTimeout bounds the connection to the exit's server; the exit is another data centre, not a local peer. DialTimeout = 10 * time.Second )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Counters ¶
type Counters struct {
Bytes uint64 // people to the exit's server
BytesBack uint64 // the exit's server to people
Packets uint64
PacketsBack uint64
TooLarge uint64 // datagrams dropped because they did not fit a buffer
DialFailed uint64 // dials of the exit that failed (TCP connections and UDP sessions)
}
Counters are the bytes of one relay since its forward was installed. Packets are datagrams for UDP and write calls for TCP: the segments of a TCP connection are the kernel's, not the forwarder's to count.
type Forward ¶
type Forward struct {
ID string
Network string // "tcp" | "udp"
Port uint16
To netip.AddrPort
// Address is a listen address for tests; production listens on every local address of both families, so a client that
// picks the entry's AAAA record reaches the port too.
Address string
}
Forward is one port carried in userspace: the exit is always a literal address of the other family.
type Server ¶
type Server struct {
// The ceilings (New sets them from the descriptor and memory budgets) and the idle time of a TCP pair; a test lowers them
// before the first Sync.
PairsPerNode, SessionsPerNode, PairsPerPort, SessionsPerPort, PerSource int
PairIdle time.Duration
// contains filtered or unexported fields
}
Server runs the forwards of one node. Sync and Close are called from the agent's worker goroutine; Counters may be read from the doctor.
func New ¶
func New() *Server
New returns a server with no forwards, its node ceilings fitted to the agent's memory limit.
func (*Server) Close ¶
func (s *Server) Close()
Close stops every forward, closes its connections and sessions and refuses new ones; it returns when their goroutines are gone.
func (*Server) SetLogger ¶
SetLogger sets the logger of the forwards (nil is quiet) and says the ceilings once. Call it before Sync.
func (*Server) Sync ¶
Sync makes the running forwards exactly the wanted list: a forward that is gone or changed (its target, its network, its port) is stopped and started again, one that did not change keeps its connections. Per-id errors are returned for the forwards that could not be started; the others run.