portallocator

package
v1.6.2 Latest Latest
Warning

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

Go to latest
Published: May 11, 2015 License: Apache-2.0 Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

This section is empty.

Types

type ErrPortAlreadyAllocated

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

func NewErrPortAlreadyAllocated added in v1.1.0

func NewErrPortAlreadyAllocated(ip string, port int) ErrPortAlreadyAllocated

func (ErrPortAlreadyAllocated) Error added in v1.1.0

func (e ErrPortAlreadyAllocated) Error() string

func (ErrPortAlreadyAllocated) IP added in v1.1.0

func (ErrPortAlreadyAllocated) IPPort added in v1.1.0

func (e ErrPortAlreadyAllocated) IPPort() string

func (ErrPortAlreadyAllocated) Port added in v1.1.0

func (e ErrPortAlreadyAllocated) Port() int

type PortAllocator added in v1.6.0

type PortAllocator struct {
	Begin int
	End   int
	// contains filtered or unexported fields
}

func New added in v1.6.0

func New() *PortAllocator

func (*PortAllocator) ReleaseAll added in v1.6.0

func (p *PortAllocator) ReleaseAll() error

ReleaseAll releases all ports for all ips.

func (*PortAllocator) ReleasePort added in v1.6.0

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 added in v1.6.0

func (p *PortAllocator) 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.

Jump to

Keyboard shortcuts

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