Documentation
¶
Overview ¶
Package netutil provides some network utility functions. Some of them are supported only on Linux.
Index ¶
- func AddAddr(intf *net.Interface, ip net.IP, ipNet *net.IPNet, label string) error
- func DelAddr(intf *net.Interface, ip net.IP, ipNet *net.IPNet) error
- func HasAddr(intf *net.Interface, ip net.IP) (bool, error)
- func IPNetEqual(ipNet1, ipNet2 *net.IPNet) bool
- func IPNetTo4IfV4(ipNet *net.IPNet) *net.IPNet
- func IPTo4IfV4(ip net.IP) net.IP
- func InterfaceByIP(ip net.IP) (*net.Interface, error)
- func IsUniqueLocal(ip net.IP) bool
- func ParseIP(s string) net.IP
- func SendGARP(intf *net.Interface, ip net.IP) error
- func SplitHostPort(hostPort string) (host string, port int, err error)
- type IP
- type IPAndNet
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IPNetEqual ¶
IPNetEqual resports whether ipNet1 and ipNet2 are the same IP network.
func IPNetTo4IfV4 ¶
IPNetTo4IfV4 returns the IP network with IP replaced with IPto4If4().
func InterfaceByIP ¶
InterfaceByIP return the interface matched by the IP address.
func IsUniqueLocal ¶
IsUniqueLocal reports whether ip is a unique local address.
The identification of unique local addresses uses address type identification as defined in "Local IPv6 Unicast Addresses" section of RFC 4193 and "Private Address Space" in RFC 1918.
func ParseIP ¶
ParseIP parses s as an IP address using net.ParseIP(), and converts the IP with IPTo4Ifv4().
Types ¶
type IP ¶
IP is an IP address which can be marshaled and marshaled to YAML.
func (IP) MarshalYAML ¶
MarshalYAML marshal an IP address to string.
func (*IP) UnmarshalYAML ¶
UnmarshalYAML unmarshal an IP address string from YAML.
type IPAndNet ¶
IPAndNet is an IP address with IPNet which can be marshaled and marshaled to YAML.
func ParseCIDR ¶
ParseCIDR parses s as a CIDR using net.ParseCIDR(), and converts the IP with IPTo4Ifv4().
func (*IPAndNet) Equal ¶
Equal reports whether i and j are the same IP address and network. IP addresses are compared with IP.Equal and networks are compared with the results of IPNet.String().
func (IPAndNet) MarshalYAML ¶
MarshalYAML marshal an IP address and network to string.
func (*IPAndNet) UnmarshalYAML ¶
UnmarshalYAML unmarshal an CIDR address string from YAML.