Documentation
¶
Overview ¶
Package netbind ties sockets to a network interface or a local address: listeners that accept on chosen interfaces only, and outgoing connections that leave through a chosen interface.
An interface is bound to as a device where the system can (Linux: SO_BINDTODEVICE, macOS: IP_BOUND_IF), so routing cannot send the packets elsewhere, and a connection accepted on it answers through it. Elsewhere, the interface's addresses stand for it.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Dialer ¶
func Dialer(source string, timeout time.Duration, control func(network, address string, c syscall.RawConn) error) *net.Dialer
Dialer returns a dialer whose connections leave from source: an interface name, an IP address, or empty for wherever routing says. control, if not nil, also runs on each socket. The interface is looked up at each dial, so it may come up after the dialer is made.
func FastOpenHint ¶ added in v0.0.4
func FastOpenHint() string
FastOpenHint returns what the system needs for clients' TCP Fast Open, "" for nothing.
func Interface ¶
Interface returns the interface named name, nil if name is an IP address, a host name or empty.
Types ¶
type Spread ¶ added in v0.0.4
type Spread struct {
// contains filtered or unexported fields
}
Spread dials from several sources in turn, so connections to a server share them: a server that caps the connections from one address allows more over several. A dial that fails is tried from the next source.
func NewSpread ¶ added in v0.0.4
func NewSpread(sources []string, timeout time.Duration, control func(network, address string, c syscall.RawConn) error) *Spread
NewSpread returns a Spread over sources (interface names or local IP addresses; none for wherever routing says), starting at a random one. control is as for Dialer.