network

package
v1.2.20 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2025 License: MIT Imports: 2 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IPInCIDR added in v1.2.19

func IPInCIDR(ip, cidr string) (inCIDR bool)

IPInCIDR determines whether a given IP address is in a given CIDR. It parses the IP address and CIDR from strings and checks if the IP address is in the CIDR.

Parameters:

ip (string): The IP address in string format to be checked.
cidr (string): The CIDR in string format to be checked.

Returns:

inCIDR (bool): Returns true if the IP address is in the CIDR, false otherwise.

func IsPrivateIP

func IsPrivateIP(ip string) (isPrivate bool)

IsPrivateIP determines whether a given IP address is a private IP address. It parses the IP address from a string and checks it against a list of predefined private IP blocks.

Parameters:

ip (string): The IP address in string format to be checked.

Returns:

isPrivate (bool): Returns true if the IP address is a private IP address,
                  false otherwise.

func IsValidHostPort added in v1.2.20

func IsValidHostPort(hostPort string) (isValid bool)

func IsValidIP added in v1.2.19

func IsValidIP(ip string) (isValid bool)

IsValidIP determines whether a given IP address is a valid IP address. It parses the IP address from a string and checks if the parsed IP is not nil.

Parameters:

ip (string): The IP address in string format to be checked.

Returns:

isValid (bool): Returns true if the IP address is a valid IP address,
                false otherwise.

func IsValidIPOrCIDR added in v1.2.19

func IsValidIPOrCIDR(ipOrCIDR string) (isValid bool)

IsValidIPOrCIDR determines whether a given string is a valid IP address or CIDR. It first parses the string as an IP address, if it fails, it then parses the string as a CIDR. If both parsing operations fail, the string is not a valid IP address or CIDR.

Parameters:

ipOrCIDR (string): The IP address or CIDR in string format to be checked.

Returns:

isValid (bool): Returns true if the string is a valid IP address or CIDR,
                false otherwise.

Types

This section is empty.

Jump to

Keyboard shortcuts

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