Documentation ¶
Overview ¶
Package bindtodevice contains an implementation of the netext.ListenConfig interface that uses Linux's SO_BINDTODEVICE socket option to be able to bind to a device.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ControlConfig ¶
type ControlConfig struct { // RcvBufSize defines the size of socket receive buffer in bytes. Default // is zero (uses system settings). RcvBufSize int // SndBufSize defines the size of socket send buffer in bytes. Default is // zero (uses system settings). SndBufSize int }
ControlConfig is the configuration of socket options.
type DefaultInterfaceStorage ¶
type DefaultInterfaceStorage struct{}
DefaultInterfaceStorage is the storage that uses the OS's network interfaces.
func (DefaultInterfaceStorage) InterfaceByName ¶
func (DefaultInterfaceStorage) InterfaceByName(name string) (iface NetInterface, err error)
InterfaceByName implements the InterfaceStorage interface for DefaultInterfaceStorage.
type InterfaceStorage ¶
type InterfaceStorage interface {
InterfaceByName(name string) (iface NetInterface, err error)
}
InterfaceStorage is the interface for storages of network interfaces (aka devices). Its main implementation is DefaultInterfaceStorage.
type ListenConfig ¶
type ListenConfig struct {
// contains filtered or unexported fields
}
ListenConfig is a netext.ListenConfig implementation that uses the provided channel-based packet connection and listener to implement the methods of the interface.
netext.ListenConfig instances of this type are the ones that are going to be set as [dnsserver.ConfigBase.ListenConfig] to make the bind-to-device logic work.
func (*ListenConfig) Addr ¶
func (lc *ListenConfig) Addr() (addr *agdnet.PrefixNetAddr)
Addr returns the address on which lc accepts connections. addr.Net is empty.
func (*ListenConfig) Listen ¶
func (lc *ListenConfig) Listen( ctx context.Context, network string, address string, ) (l net.Listener, err error)
Listen implements the netext.ListenConfig interface for *ListenConfig.
func (*ListenConfig) ListenPacket ¶
func (lc *ListenConfig) ListenPacket( ctx context.Context, network string, address string, ) (c net.PacketConn, err error)
ListenPacket implements the netext.ListenConfig interface for *ListenConfig.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager creates individual listeners and dispatches connections to them.
func NewManager ¶
func NewManager(c *ManagerConfig) (m *Manager)
NewManager returns a new manager of interface listeners.
func (*Manager) Add ¶
Add creates a new interface-listener record in m. If conf is nil, a default configuration is used.
Add must not be called after Start is called.
func (*Manager) ListenConfig ¶
ListenConfig returns a new *ListenConfig that receives connections from the interface listener with the given id and the destination addresses of which fall within subnet. subnet should be masked.
ListenConfig must not be called after Start is called.
func (*Manager) Shutdown ¶
Shutdown implements the service.Interface interface for *Manager. Shutdown does not actually wait for all sockets to close. If m is nil, Shutdown returns nil, since this feature is optional.
TODO(a.garipov): Consider waiting for all sockets to close.
TODO(a.garipov): Use the context for cancelation.
TODO(a.garipov): Consider an interface solution instead of the nil exception.
func (*Manager) Start ¶
Start implements the service.Interface interface for *Manager. If m is nil, Start returns nil, since this feature is optional.
TODO(a.garipov): Consider an interface solution instead of the nil exception.
TODO(a.garipov): Use the context for cancelation.
type ManagerConfig ¶
type ManagerConfig struct { // InterfaceStorage is used to get the information about the system's // network interfaces. Normally, this is [DefaultInterfaceStorage]. InterfaceStorage InterfaceStorage // ErrColl is the error collector that is used to collect non-critical // errors. ErrColl errcoll.Interface // ChannelBufferSize is the size of the buffers of the channels used to // dispatch TCP connections and UDP sessions. ChannelBufferSize int }
ManagerConfig is the configuration structure for NewManager. All fields must be set.
type NetInterface ¶
NetInterface represents a network interface (aka device).
TODO(a.garipov): Consider moving this and InterfaceStorage to netutil.