ipdiscovery

package
v0.17.2 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const NetcheckInterface = "netcheck"

NetcheckInterface is the Interface recorded on addresses netcheck observed rather than read off a local link. It names no real interface.

Variables

This section is empty.

Functions

This section is empty.

Types

type Address

type Address struct {
	Interface string `json:"interface"`
	IP        string `json:"ip"`
	Network   string `json:"network"`
	IsIPv6    bool   `json:"is_ipv6"`

	// LinkType is the kernel's name for the kind of link the address sits
	// on ("device", "tuntap", "wireguard", "bridge", …), empty where the
	// platform can't say. Tun and tap devices both report "tuntap".
	LinkType string `json:"link_type,omitempty"`
	// PointToPoint is set for links with no broadcast domain, which is how
	// tunnels (tun devices, WireGuard) present themselves.
	PointToPoint bool `json:"point_to_point,omitempty"`
}

Address represents an IP address associated with a network interface

type Discovery

type Discovery struct {
	Addresses []Address `json:"addresses"`
}

Discovery holds information about discovered IP addresses

func Discover

func Discover(ctx context.Context, log *slog.Logger, opts Options) (*Discovery, error)

Discover gathers IP addresses from local interfaces and, when configured, from an external netcheck service for public IP discovery.

func DiscoverWithTimeout

func DiscoverWithTimeout(timeout time.Duration, log *slog.Logger, opts Options) (*Discovery, error)

DiscoverWithTimeout is a convenience function that adds a timeout to Discover

type Options added in v0.7.0

type Options struct {
	// NetcheckURL, when set, enables public IP discovery via a zero-port
	// netcheck request to the given URL. On cloud providers the external IP
	// isn't on any local interface, so this is the only way to find it.
	NetcheckURL string
}

Options configures IP discovery behavior.

Jump to

Keyboard shortcuts

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