Documentation
¶
Overview ¶
Package ports handles port allocation, sticky auto-ports, and conflict detection.
Index ¶
- func FindFree() (uint16, error)
- func FindFreeExcluding(allocated map[uint16]bool) (uint16, error)
- func IsAvailable(port uint16) bool
- func Resolve(portCfg *config.Port, label string, prevPort *uint16, prevAuto bool, ...) (uint16, bool, error)
- func ResolveFixed(portCfg config.Port, label string, allocated map[uint16]bool) (uint16, error)
- type Conflict
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FindFree ¶
FindFree finds an available ephemeral port by binding to :0 and reading the assigned port from the OS.
func FindFreeExcluding ¶
FindFreeExcluding finds a free port not in the allocated set.
func IsAvailable ¶
IsAvailable returns true if the given TCP port is free on localhost.
func Resolve ¶
func Resolve(portCfg *config.Port, label string, prevPort *uint16, prevAuto bool, allocated map[uint16]bool) (uint16, bool, error)
Resolve returns a concrete port number for a config Port value. If the port is Auto, it tries to reuse prevPort (sticky auto-port) if it's still free, otherwise finds a fresh one. The chosen port is added to allocated.
Types ¶
type Conflict ¶
Conflict describes a port already in use before devrig starts.
func CheckFixed ¶
CheckFixed verifies that all fixed (non-auto) ports in the config are free on the system right now. Returns one Conflict per violation.