ipcheck

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2024 License: MIT Imports: 2 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidLocalIP  = errors.New("local ip is invalid")
	ErrInvalidRemoteIP = errors.New("remote ip is invalid")
)

Error variables for invalid IP addresses

Functions

func IsBogon

func IsBogon(ip net.IP, extra ...func(net.IP) bool) bool

IsBogon returns true if dialing the address would fail due to gonet restrictions. A bogon address is a packet routed on the public internet that claims to originate from an area of the IP address space reserved or not yet allocated. This function checks against known bogon conditions including loopback, link-local, and other special addresses. Additional conditions can be specified through the extra parameter.

func IsLinkLocal

func IsLinkLocal(ip net.IP) bool

IsLinkLocal determines if the provided IP address is a link-local address. Link-local addresses are used in a single network segment and not routable on the larger internet. This function checks if the IP belongs to the IPv4 link-local range (169.254.0.0/16) or the IPv6 link-local range (fe80::/64).

func IsLoopback

func IsLoopback(ip net.IP) bool

IsLoopback determines if the IP is either the standard IPv6 loopback (::1) or within the IPv4 loopback range.

func IsPrivateNetwork

func IsPrivateNetwork(ip net.IP) bool

IsPrivateNetwork returns true if the address belongs to a private network. This function checks against standard private IPv4 ranges (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16) and the IPv6 unique local address range (fd00::/8).

Types

This section is empty.

Jump to

Keyboard shortcuts

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