portallocator

package
v1.4.2-0...-e6b7d93 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 24, 2015 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultPortRangeStart = 49153
	DefaultPortRangeEnd   = 65535
)

Variables

View Source
var (
	ErrAllPortsAllocated = errors.New("all ports are allocated")
	ErrUnknownProtocol   = errors.New("unknown protocol")
)

Functions

func PortRange

func PortRange() (int, int)

func ReleaseAll

func ReleaseAll() error

func ReleasePort

func ReleasePort(ip net.IP, proto string, port int) error

func RequestPort

func RequestPort(ip net.IP, proto string, port int) (int, error)

RequestPort requests new port from global ports pool for specified ip and proto. If port is 0 it returns first free port. Otherwise it cheks port availability in pool and return that port or error if port is already busy.

Types

type ErrPortAlreadyAllocated

type ErrPortAlreadyAllocated struct {
	// contains filtered or unexported fields
}

func NewErrPortAlreadyAllocated

func NewErrPortAlreadyAllocated(ip string, port int) ErrPortAlreadyAllocated

func (ErrPortAlreadyAllocated) Error

func (e ErrPortAlreadyAllocated) Error() string

func (ErrPortAlreadyAllocated) IP

func (ErrPortAlreadyAllocated) IPPort

func (e ErrPortAlreadyAllocated) IPPort() string

func (ErrPortAlreadyAllocated) Port

func (e ErrPortAlreadyAllocated) Port() int

type PortAllocator

type PortAllocator struct {
	// contains filtered or unexported fields
}

func New

func New() *PortAllocator

func (*PortAllocator) ReleaseAll

func (p *PortAllocator) ReleaseAll() error

ReleaseAll releases all ports for all ips.

func (*PortAllocator) ReleasePort

func (p *PortAllocator) ReleasePort(ip net.IP, proto string, port int) error

ReleasePort releases port from global ports pool for specified ip and proto.

func (*PortAllocator) RequestPort

func (p *PortAllocator) RequestPort(ip net.IP, proto string, port int) (int, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL