addr

package
v4.0.0-...-699247e Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2023 License: Apache-2.0 Imports: 2 Imported by: 0

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 be itterated over to find an IP address, prefferably 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