util

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2020 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DetectAddress

func DetectAddress(detector string, addrType AddressType, ifaceNames []string) (string, error)

DetectAddress picks the appropriate IP detection method based on `detector`.

func DetectByInterface

func DetectByInterface(addrType AddressType, ifaceNames []string) (string, error)

DetectByInterface finds the most-likely public IP address as a string, by inspecting addresses assigned to OS network interfaces. If ifaceNames are not empty, it will filter ip addresses based on the associated interface name.

func Resolve

func Resolve(servers []string, recordType uint16, name string) string

Resolve resolves a DNS `recordType` dns.Type enum for `name` by querying servers.

func ResolveOs

func ResolveOs(recordType uint16, name string) string

ResolveOs returns a DNS `recordType` dns.Type enum for `name` by using operating system's resolver. Currently, only supports TypeA and TypeAAAA.

Types

type AddressType

type AddressType int

AddressType denotes the type of IP address.

const (
	// IP4 represents IPv4 address.
	IP4 AddressType = iota
	// IP6 represents IPv6 address.
	IP6 AddressType = iota
)

func GetAddressType

func GetAddressType(ipAddr net.IP) AddressType

GetAddressType returns the AddressType of the given IP.

Jump to

Keyboard shortcuts

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