Documentation ¶
Overview ¶
Package net provides convenience types around types from the golang/net package.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNoPortrangerProvided = errors.New("no portranger provided")
Functions ¶
func AnonymizeIPString ¶
func AnonymizeIPv4 ¶
IPv4 anonymizes an IPv4 address by zeroing it's host part.
func AnonymizeIPv6 ¶
IPv6 anonymizes an IPv4 address by zeroing it's host part.
func GetPublicIPs ¶ added in v16.11.0
GetPublicIPs will try to figure out the public IPs (v4 and v6) we're running on. If it fails, an empty list will be returned.
Types ¶
type IPLimiter ¶
type IPLimiter interface { // Tests whether the IP is allowed in respect to the underlying implementation IsAllowed(ip string) bool }
The IPLimiter interface allows to check whether a certain IP is allowed.
func NewIPLimiter ¶
NewIPLimiter creates a new IPLimiter with the given IP ranges for the allowed and blocked IPs. Empty strings are ignored. Returns an error if an invalid IP range has been found.
func NewNullIPLimiter ¶
func NewNullIPLimiter() IPLimiter
type Portranger ¶
type Portranger interface { // Get a new port from the pool. The port is from the range as providied at initialization. // If no more ports are available a negative port is returned and error is not nil. Get() (int, error) // Put a port back in the pool. It will be silently ignored if a port has already been returned back // to the pool or if the returned port is not in the range. Put(int) }
The Portranger interface allows to get an available port from a pool and to put it back after use for later re-use.
func NewDummyPortrange ¶
func NewDummyPortrange() Portranger
func NewPortrange ¶
func NewPortrange(min, max int) (Portranger, error)
NewPortrange returns a new instance of a Portranger implementation. A minimal and maximal port number have to be provided for a valid port range. If the provided port range is invalid, nil and an error is retuned.