ipdiscovery

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

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"`
}

Address represents an IP address associated with a network interface

type Discovery

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

Discovery holds information about discovered IP addresses

func Discover

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

Discover gathers all local interface addresses and the public IP

func DiscoverWithTimeout

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

DiscoverWithTimeout is a convenience function that adds a timeout to Discover

type PublicIPResponse

type PublicIPResponse struct {
	IP      string `json:"ip"`
	Country string `json:"country"`
	City    string `json:"city"`
}

PublicIPResponse represents the response from ifconfig.co/json

Jump to

Keyboard shortcuts

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