port

package
v0.0.0-...-c97221a Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrEmptyServerAddressList = errors.New("empty server address list specified")

ErrEmptyServerAddressList indicates there are no servers to get response from

Functions

func GloballyReachable

func GloballyReachable(ctx context.Context, port Port, echoServerAddresses []string, timeout time.Duration) (bool, error)

GloballyReachable checks if UDP port is reachable from global Internet, performing probe against asymmetric UDP echo server

Types

type Pool

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

Pool hands out ports for service use

func NewFixedRangePool

func NewFixedRangePool(r Range) *Pool

NewFixedRangePool creates a fixed size pool from port.Range

func (*Pool) Acquire

func (pool *Pool) Acquire() (Port, error)

Acquire returns an unused port in pool's range

func (*Pool) AcquireMultiple

func (pool *Pool) AcquireMultiple(n int) (ports []Port, err error)

AcquireMultiple returns n unused ports from pool's range.

type Port

type Port int

Port (networking)

func (Port) Num

func (p Port) Num() int

Num returns port's numeric value

type Range

type Range struct {
	Start, End int
}

Range represents a networking port range

func ParseRange

func ParseRange(rangeExpr string) (Range, error)

ParseRange parses port range expression, e.g. "1000:1200" into Range struct

func (*Range) Capacity

func (r *Range) Capacity() int

Capacity returns range capacity

func (*Range) String

func (r *Range) String() string

String returns port range expression, e.g. "1000:1200"

type ServicePortSupplier

type ServicePortSupplier interface {
	Acquire() (Port, error)
	AcquireMultiple(n int) (ports []Port, err error)
}

ServicePortSupplier provides port needed to run a service on

Jump to

Keyboard shortcuts

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