iana

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package iana provides a lookup table of IANA service name assignments built from the official service-names-port-numbers CSV registry.

No data is bundled in the binary. On first use LoadEffective auto-downloads the CSV from the configured URL and caches it in the user config directory. Subsequent calls load from the cache. Manual refresh is available via Sync or the config TUI sync button.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CachePath

func CachePath() (string, error)

CachePath returns the path for the user-downloaded CSV.

func LastSyncTime

func LastSyncTime() (time.Time, bool)

LastSyncTime returns the modification time of the user cache file and whether the cache exists at all.

func Sync

func Sync(url string) error

Sync downloads the IANA CSV from url and writes it to the user cache directory atomically. The cache is used by LoadEffective on the next call.

Types

type DB

type DB map[portKey]Entry

DB is a loaded IANA registry keyed by (port, protocol).

func LoadEffective

func LoadEffective(url string) (DB, error)

LoadEffective loads the IANA registry from the user cache when it exists. If the cache is absent or corrupt it auto-downloads a fresh copy from url and caches it before returning. On download failure it returns an empty DB and a non-nil error so callers can degrade gracefully (ports show as N/tcp).

func (DB) Lookup

func (db DB) Lookup(port int, proto string) (Entry, bool)

Lookup returns the IANA entry for port and proto ("tcp"/"udp"). Falls back to a protocol-agnostic entry when no exact match exists.

type Entry

type Entry struct {
	ServiceName             string
	PortNumber              string // stored as string to preserve original value
	TransportProtocol       string
	Description             string
	Assignee                string
	Contact                 string
	RegistrationDate        string
	ModificationDate        string
	Reference               string
	ServiceCode             string
	UnauthorizedUseReported string
	AssignmentNotes         string
}

Entry is a single IANA port assignment with all registry columns preserved. Field names match the official CSV header so callers can write them verbatim.

Jump to

Keyboard shortcuts

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