ifbind

package
v0.39.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 24, 2026 License: Apache-2.0 Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

func Control(iface string) func(network, address string, c syscall.RawConn) error

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL