Documentation
¶
Overview ¶
Package ifbind binds a socket to a network interface. On Linux the kernel then hands the socket only what arrives on that interface. On macOS the binding confines what the socket sends to that interface and does not filter what it receives. The round-trip probe and the tcp session listener use it to bind their sockets to the mesh interface.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Control ¶
Control returns the net.ListenConfig control that binds a socket to iface: IP_BOUND_IF at IPPROTO_IP, or IPV6_BOUND_IF at IPPROTO_IPV6 when network ends in "6". It returns nil for an empty iface, so the socket is bound to its address alone. The control looks up the index of iface when it runs, not when Control is called. An unknown iface or a refused option fails the listen with the error wrapped as "bind to interface <iface>: <error>".
On macOS the option confines what the socket sends to iface. It does not filter what the socket receives: on a host that forwards, a socket bound to iface still receives what arrives for its address on another interface, and its answers leave through iface. IPV6_BOUND_IF is the counterpart from netinet6/in6.h that Tailscale's netns_darwin.go sets for IPv6 sockets. Nothing beyond the unit test measures it here.
Types ¶
This section is empty.