Documentation
¶
Overview ¶
Package socks is the SOCKS application: internet egress as a service the node's own tailnet address names. RFC 1928 CONNECT and UDP ASSOCIATE are served on a gVisor netstack the node runs in-process — the machinery the egress already was, its forwarders left behind with the default they served — with the listener as the serving surface and the flow bounds, idle sweep, and dial timeout unchanged. The application assembles beside the WireGuard application and borrows its router the way the coordination application borrows its store: the node's own address — the slice's first, which the coordination allocator never issues — stands delivered to the application's inbound path exactly while the application runs, and the packets the netstack produces route back to whatever device the destination claims. It carries no selection semantics of its own: the applications table selects it, and it loads beside the WireGuard application wherever that loads — every node offering by default.
Index ¶
Constants ¶
const PayloadBudget = wireguard.OverlayMTU - 20 - 8 - 10
PayloadBudget is the payload an application should assume one UDP datagram through the service carries: the tunnel's inner MTU less the IPv4 and UDP headers and the ten-byte SOCKS UDP header. It is advisory on the inbound wire, where the router's MTU enforcement already bounds the reply.
const ( // Port is the registered SOCKS port the listener binds on the node's // own address — a code constant beside the flow bounds, so no argument // grows and every client knows it by convention. Port = 1080 )
The SOCKS dialect (RFC 1928): method none is the one offer — tailnet reachability is the admission, hosts existing only through registration at the one seam; CONNECT and UDP ASSOCIATE are the two commands served, BIND refused; a datagram with FRAG set is refused; nothing relays UDP inside TCP; and a UDP ASSOCIATE reply names the exit's true tailnet address and the relay endpoint's port, a client never asked to guess its relay.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type App ¶
type App struct {
// contains filtered or unexported fields
}
App is the SOCKS application: a netstack claiming the node's own address, the SOCKS listener bound on it, and the flow machinery — CONNECT legs spliced to the node's own sockets and UDP associations relayed through them — under the bound, the idle sweep, and the dial timeout the egress always ran.
func New ¶
New assembles the application: the netstack claims the node's own address on a link endpoint the borrowed router feeds, the SOCKS listener binds the registered port on that address alone, and the flow tables stand empty. The delivery installs here and uninstalls at Close: the address is routed exactly while the application exists. A failed assembly destroys the netstack it created.
func (*App) Close ¶
func (a *App) Close()
Close retires the application: the served address's delivery uninstalls — the address counting unroutable again — and, when Run never ran, the netstack closes with the listener and the link beneath it; Run's stop closed them otherwise. No operating-system provisioning exists to undo, and a second call releases nothing.
func (*App) Inbound ¶
Inbound takes a plaintext packet the borrowed router delivered to the node's own address: TCP and UDP — the listener's legs and the associations' relays — enter the netstack, and everything else is dropped and counted, internet ICMP included.
func (*App) Run ¶
Run serves the application until the context is canceled: the listener accepts, netstack's own packets route toward their overlay destinations through the borrowed router, and idle flows expire. It returns once every goroutine it started has returned, and the netstack's own with them.
type Config ¶
type Config struct {
// Subnet is the node's slice of the tailnet range: the slice's first
// address — the one the coordination allocator never issues — is the
// node's own, the address the service claims and answers on.
Subnet netip.Prefix
// Router is the overlay routing the application borrows from the
// WireGuard application: packets the service produces — replies and
// relays — route to their overlay destinations, and the node's own
// address stands delivered to the application's inbound path exactly
// while the application runs. Without the WireGuard application there
// is nothing to borrow, and this application does not assemble.
Router wireguard.Router
// Idle overrides the flow idle bound, for tests; zero means the
// constant.
Idle time.Duration
// Flows overrides the flow bound, for tests; zero means the constant.
Flows int
// Handshake overrides the handshake bound, for tests; zero means the
// dial timeout.
Handshake time.Duration
// Dial overrides how a CONNECT dials its internet leg, for tests; nil
// means the node's own sockets under the dial timeout.
Dial func(ctx context.Context, network, address string) (net.Conn, error)
}
Config configures the application.
type Owner ¶
type Owner interface {
// Subnet returns the node's assigned slice of the tailnet range,
// waiting for the directory's answer.
Subnet(ctx context.Context) (netip.Prefix, error)
// Router returns the overlay routing the application borrows.
Router() wireguard.Router
}
Owner is the WireGuard application's surface the SOCKS application borrows: the assigned slice its serving waits for and the router the netstack rides.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the SOCKS application's serving form: the wait for the directory's assignment — the publication's answer — and, once it arrives, the application that claims the slice's first address. The construction is a publication's answer, not a boot's fact: the application assembles one publication later than the WireGuard application's own, and a node that serves no hosts serves no one.
func NewServer ¶
NewServer stands the serving form beside the WireGuard application whose router and assigned slice it borrows.
func (*Server) Close ¶
func (s *Server) Close()
Close releases nothing: the serving form binds nothing of its own, and Run releases the application it assembled before it returns.
func (*Server) HTTPSHandler ¶
HTTPSHandler is nil: the application's serving surface is its own listener on the overlay, and it mounts nothing on the node's HTTPS server.