net_util

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ACL_NOT_FOUND = "acl_not_found" // it is used when clientip is not found in acl table
)

Variables

This section is empty.

Functions

func IPv4StrToUint32

func IPv4StrToUint32(ipStr string) (uint32, error)

IPv4StrToUint32 convert IPv4 string to uint32

e.g., "1.2.3.4" to 0x01020304

Params:

  • ipStr: IPv4 addr in string

Returns:

IPv4 addr in uint32

func IPv4ToUint32

func IPv4ToUint32(ipBytes net.IP) (uint32, error)

IPv4ToUint32 convert net.IP to uint32

e.g., 1.2.3.4 to 0x01020304

Params:

  • ipBytes: IPv4 addr in net.IP

Returns:

IPv4 addr in uint32

func InRange

func InRange(r IpRange, ip net.IP) bool

InRange checks whether a given ip address is within a range given

func IsIPv4Address

func IsIPv4Address(input string) bool

IsIPv4Address Check input is ipv4 address or not.

param:

  • input: a string

return:

bool

func IsPrivateIp

func IsPrivateIp(input string) bool

IsPrivateIp Check to see if an ip is in a private subnet.

param:

  • input: an ip string

return:

bool

func ParseIPv4

func ParseIPv4(s string) net.IP

ParseIPv4 parse IP addr from string to net.IP

Params:

  • s: IP addr in string, e.g., "1.2.3.4"

Returns:

IP addr in net.IP

func Uint32ToIPv4

func Uint32ToIPv4(ipNum uint32) net.IP

Uint32ToIPv4 convert uint32 net.IP

e.g., 0x01020304 to 1.2.3.4

Params:

  • ipNum: IPv4 addr in uint32

Returns:

IPv4 addr in net.IP

func Uint32ToIPv4Str

func Uint32ToIPv4Str(ipNum uint32) string

Uint32ToIPv4Str convert uint32 to str

e.g., 0x01020304 to "1.2.3.4"

Params:

  • ipNum: IPv4 addr in uint32

Returns:

IPv4 addr in string

Types

type AclTable

type AclTable struct {
	// contains filtered or unexported fields
}

func NewAclTable

func NewAclTable() *AclTable

func (*AclTable) GetAclName

func (t *AclTable) GetAclName(ip string) string

func (*AclTable) LoadFromFile

func (t *AclTable) LoadFromFile(file *os.File) error

type IpRange

type IpRange struct {
	// contains filtered or unexported fields
}

IpRange - a structure that holds the start and end of a range of ip addresses

Jump to

Keyboard shortcuts

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