Documentation
¶
Overview ¶
Package netbind keeps sockets on one network interface, such as a VPN's wg0, so their traffic can't take another route when the interface goes away: connecting fails instead. It sets SO_BINDTODEVICE on Linux and IP_BOUND_IF on macOS.
Index ¶
- Variables
- type Binder
- func (b *Binder) Control(network, _ string, c syscall.RawConn) error
- func (b *Binder) DialContext(ctx context.Context, network, addr string) (net.Conn, error)
- func (b *Binder) Dialer() *net.Dialer
- func (b *Binder) ListenPacket(network, addr string) (net.PacketConn, error)
- func (b *Binder) Name() string
- func (b *Binder) Resolver() *net.Resolver
- func (b *Binder) State() State
- type State
Constants ¶
This section is empty.
Variables ¶
var ErrUnsupported = errors.New("binding to a network interface is supported on Linux and macOS only")
ErrUnsupported is returned on platforms that can't bind to an interface.
Functions ¶
This section is empty.
Types ¶
type Binder ¶
type Binder struct {
// contains filtered or unexported fields
}
Binder binds sockets to an interface. A nil Binder binds nothing.
func (*Binder) Control ¶
Control binds a socket to the interface; it is a net.Dialer's and a net.ListenConfig's Control. It fails when the interface doesn't exist.
func (*Binder) DialContext ¶
DialContext connects through the interface.
func (*Binder) ListenPacket ¶
func (b *Binder) ListenPacket(network, addr string) (net.PacketConn, error)
ListenPacket opens a UDP socket bound to the interface.