port

package
v0.0.0-...-5f4265e Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2015 License: Apache-2.0 Imports: 11 Imported by: 140

Documentation

Overview

Provides port allocation and reservation.

Ports are a limited resource on a host and so must be shared via a central allocator. This package exposes Port - a valid IP port value - and methods for allocation and reservation of those ports.

Index

Constants

View Source
const InvalidPort = 0

Variables

View Source
var ErrAllocationFailed = errors.New("A port could not be allocated.")

Functions

This section is empty.

Types

type Device

type Device string

type HostPort

type HostPort struct {
	Host string `json:"Host,omitempty"`
	Port `json:"Port,omitempty"`
}

A host and port combination, where Host may be empty

func NewHostPort

func NewHostPort(hostport string) (HostPort, error)

func (HostPort) Empty

func (hostport HostPort) Empty() bool

func (HostPort) Local

func (hostport HostPort) Local() bool

func (HostPort) String

func (hostport HostPort) String() string

type Port

type Port uint

An IP port, valid from 1 to 65535. Use 0 for undefined.

func NewPortFromString

func NewPortFromString(value string) (Port, error)

func (Port) Check

func (p Port) Check() error

func (Port) Default

func (p Port) Default() bool

func (Port) String

func (p Port) String() string

type PortAllocator

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

An example of a very simple Port allocator.

func NewPortAllocator

func NewPortAllocator(base string, min, max Port) *PortAllocator

func (*PortAllocator) Run

func (p *PortAllocator) Run()

type PortPair

type PortPair struct {
	Internal Port
	External Port `json:"External,omitempty"`
}

type PortPairs

type PortPairs []PortPair

func FromPortPairHeader

func FromPortPairHeader(s string) (PortPairs, error)

func (PortPairs) Find

func (p PortPairs) Find(port Port) (*PortPair, bool)

func (PortPairs) String

func (p PortPairs) String() string

func (PortPairs) ToHeader

func (p PortPairs) ToHeader() string

type PortReservation

type PortReservation struct {
	*PortAllocator
}

func (*PortReservation) AtomicReserveExternalPorts

func (a *PortReservation) AtomicReserveExternalPorts(path string, ports, existing PortPairs) (PortPairs, error)

func (*PortReservation) ReleaseExternalPorts

func (a *PortReservation) ReleaseExternalPorts(ports PortPairs) error

type Ports

type Ports []Port

Jump to

Keyboard shortcuts

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