port

package
v0.0.0-...-88921fd Latest Latest
Warning

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

Go to latest
Published: May 22, 2014 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

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

func ReleaseExternalPorts

func ReleaseExternalPorts(ports PortPairs) error

func StartPortAllocator

func StartPortAllocator(min, max Port)

Types

type Device

type Device string

func (Device) DevicePath

func (d Device) DevicePath() 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) PortPathsFor

func (p Port) PortPathsFor() (base string, path string)

func (Port) String

func (p Port) String() string

type PortPair

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

type PortPairs

type PortPairs []PortPair

func AtomicReserveExternalPorts

func AtomicReserveExternalPorts(path string, ports, existing PortPairs) (PortPairs, error)

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

Jump to

Keyboard shortcuts

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