ports

package
v0.38.3 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package ports handles port allocation, sticky auto-ports, and conflict detection.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindFree

func FindFree() (uint16, error)

FindFree finds an available ephemeral port by binding to :0 and reading the assigned port from the OS.

func FindFreeExcluding

func FindFreeExcluding(allocated map[uint16]bool) (uint16, error)

FindFreeExcluding finds a free port not in the allocated set.

func IsAvailable

func IsAvailable(port uint16) bool

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.

func ResolveFixed

func ResolveFixed(portCfg config.Port, label string, allocated map[uint16]bool) (uint16, error)

ResolveFixed allocates a fixed-or-auto port for a dashboard/OTel endpoint, falling back to a free port if the preferred one is taken.

Types

type Conflict

type Conflict struct {
	Resource string
	Port     uint16
}

Conflict describes a port already in use before devrig starts.

func CheckFixed

func CheckFixed(cfg *config.Config) []Conflict

CheckFixed verifies that all fixed (non-auto) ports in the config are free on the system right now. Returns one Conflict per violation.

func (Conflict) Error

func (c Conflict) Error() string

Jump to

Keyboard shortcuts

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