iputils

package
v0.11.3 Latest Latest
Warning

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

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

Documentation

Overview

Package iputils implements utilities to work with IP addresses.

Index

Constants

This section is empty.

Variables

View Source
var InterfaceByName = func(s string) (Addr, error) { return net.InterfaceByName(s) }

InterfaceByName is a mocking point for net.InterfaceByName, used for tests.

Functions

func IPVersion

func IPVersion(ip net.IP) int

IPVersion tells if an IP address is IPv4 or IPv6.

func ResolveIntfAddr

func ResolveIntfAddr(intfName string, ipVer int) (net.IP, error)

ResolveIntfAddr takes the name of a network interface and IP version, and returns the first IP address of the interface that matches the specified IP version. If no IP version is specified (ipVer is 0), simply the first IP address is returned. TODO(manugarg): This functions is currently tested through options_test. We should fix that.

Types

type Addr

type Addr interface {
	Addrs() ([]net.Addr, error)
}

Addr is used for tests, allowing net.InterfaceByName to be mocked.

Jump to

Keyboard shortcuts

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