qianmo

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2023 License: MIT Imports: 6 Imported by: 1

README

阡陌

additional network functions

GitHub GitHub Action Go Report Card Coverage Status GoDoc

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound is returned when the requested item is not found.
	ErrNotFound = errors.New("Not found")
)

Functions

func Addrs

func Addrs(name string) []string

Addrs returns the IP addresses of the interface with the given iface name.

func FreePort

func FreePort() (port int, err error)

FreePort returns a free port.

func HostFirstIPv4

func HostFirstIPv4() (string, error)

HostFirstIPv6 returns the first non-loopback IPv4 address of the host.

func HostFirstIPv6

func HostFirstIPv6() (string, error)

HostFirstIPv6 returns the first non-loopback IPv6 address of the host.

func HostIP

func HostIP() ([]string, error)

HostIP returns the IP addresses of the host.

func InterfaceByIP

func InterfaceByIP(ip string) (*net.Interface, error)

InterfaceByIP returns the interface with the given IP address.

func InterfaceByMAC

func InterfaceByMAC(mac net.HardwareAddr) (*net.Interface, error)

InterfaceByMAC returns the interface with the given MAC address.

func InterfaceByName

func InterfaceByName(name string) (*net.Interface, error)

InterfaceByName returns the interface with the given name.

func LoopbackAddrs

func LoopbackAddrs() []string

LoopbackAddrs returns the loopback IP addresses of interfaces.

func LoopbackInterface

func LoopbackInterface() (*net.Interface, error)

LoopbackInterface returns the loopback interface.

func MacByIP

func MacByIP(ip string) (net.HardwareAddr, error)

MacByIP returns the MAC address of the interface with the given IP address.

func MacByName

func MacByName(name string) (net.HardwareAddr, error)

MacByName returns the MAC address of the interface with the given name.

func NonLoopbackAddrs

func NonLoopbackAddrs() []string

NonLoopbackAddrs returns the non-loopback IP addresses of interfaces.

func NonLoopbackInterfaces

func NonLoopbackInterfaces() ([]*net.Interface, error)

NonLoopbackInterfaces returns the non-loopback interfaces.

func Route

func Route(dst string) (iface *net.Interface, gateway, preferredSrc net.IP, err error)

Route returns the interface, gateway and preferred source IP address for the given destination.

func RouteWithSrc

func RouteWithSrc(input net.HardwareAddr, src, dst string) (iface *net.Interface, gateway, preferredSrc net.IP, err error)

RouteWithSrc returns the interface, gateway and preferred source IP address for the given destination and source.

Types

This section is empty.

Jump to

Keyboard shortcuts

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