util

package
v0.0.0-...-035f8e2 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const Any = ""

Network address which represent any address. This is the default that we should use when checking if port is free.

View Source
const Loopback = "0.0.0.0"

Loopback network address. octopus should not bind to 0.0.0.0 unless we really want to expose something to the network.

Variables

This section is empty.

Functions

func AllocatePort

func AllocatePort(isPortAvailable func(int32) bool, desiredPort int32) int32

AllocatePort looks for a port close to desiredPort, using the provided implementation of isPortAvailable to determine what ports can be used. We deal with wrapping and avoid allocating ports < 1024 TODO(nkubala)09/14/21: plumb through context from callers

func GetAvailablePort

func GetAvailablePort(address string, port int, usedPorts *PortSet) int

GetAvailablePort returns an available port that is near the requested port when possible. First, check if the provided port is available on the specified address and INADDR_ANY. If so, use it. If not, check if any of the next 10 subsequent ports are available. If not, check if any of ports 4503-4533 are available. If not, return a random port, which hopefully won't collide with any future containers

See https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.txt

func IsPortFree

func IsPortFree(address string, p int) bool

Types

type PortSet

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

func (*PortSet) Delete

func (f *PortSet) Delete(port int)

func (*PortSet) Length

func (f *PortSet) Length() int

func (*PortSet) List

func (f *PortSet) List() []int

func (*PortSet) LoadOrSet

func (f *PortSet) LoadOrSet(port int) bool

func (*PortSet) Set

func (f *PortSet) Set(port int)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳