addr

package
v0.0.0-...-c935d06 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2024 License: Apache-2.0 Imports: 2 Imported by: 8

Documentation

Overview

addr provides functions to retrieve local IP addresses from device interfaces.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrIPNotFound no IP address found, and explicit IP not provided.
	ErrIPNotFound = errors.New("no IP address found, and explicit IP not provided")
)

Functions

func Extract

func Extract(addr string) (string, error)

Extract returns a valid IP address. If the address provided is a valid address, it will be returned directly. Otherwise, the available interfaces will be iterated over to find an IP address, preferably private.

func IPs

func IPs() []string

IPs returns all available interface IP addresses.

func IsLocal

func IsLocal(addr string) bool

IsLocal checks whether an IP belongs to one of the device's interfaces.

Types

This section is empty.

Jump to

Keyboard shortcuts

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