Documentation ¶
Overview ¶
Package address supports managing access for a small pool of IP subnets using iptables.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrMaxConcurrent = errors.New("max concurrent reached")
ErrMaxConcurrent is returned when the max concurrent grants has already been reached.
Functions ¶
This section is empty.
Types ¶
type IPManager ¶
IPManager supports granting IP subnet access using iptables or ip6tables.
func NewIPManager ¶
NewIPManager creates a new instance that will allow granting up to max IP subnets concurrently. Due to overhead in iptable processing and the impact that could have on measurements, max should be small.
func (*IPManager) Grant ¶
Grant adds an iptables/ip6tables rule to allow packets from a subnet containing the given IP on the INPUT chain. On success, the caller must call Revoke to allow a new Grants in the future.
func (*IPManager) Revoke ¶
Revoke removes the iptables/ip6tables rule previously granted for the same IP.
type Manager ¶
type Manager interface { Start(port, device string) error Grant(ip net.IP) error Revoke(ip net.IP) error Stop() ([]byte, error) }
Manager manages access to a device by IP and port.
type NullManager ¶
type NullManager struct{}
NullManager implements the address.Manager interface while doing nothing.
func (*NullManager) Grant ¶
func (r *NullManager) Grant(ip net.IP) error
Grant does nothing with the given ip.
func (*NullManager) Revoke ¶
func (r *NullManager) Revoke(ip net.IP) error
Revoke does nothing with the given ip.
func (*NullManager) Start ¶
func (r *NullManager) Start(port, device string) error
Start does nothing to the given port or device.