network

package
v2.5.2 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DN   = `^([a-zA-Z0-9_]{1}[a-zA-Z0-9_-]{0,62}){1}(\.[a-zA-Z0-9_]{1}[a-zA-Z0-9_-]{0,62})*[\._]?$`
	IPv4 = `^((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])`
	IPv6 = `` /* 659-byte string literal not displayed */
)

Variables

View Source
var (
	DNPattern = regexp.MustCompile(DN)

	InvalidAddress = fmt.Errorf("invalid address")
)

Functions

func CheckAddress

func CheckAddress(urlStr string) (string, error)

CheckAddress check if urlStr is valid address (ip or FQDN) or not.

func GRPCSeverBuilder

func GRPCSeverBuilder() *gsvrBuilder

GRPCServerBuilder returns a new GRPC server builder.

func GetSingleIPAddress

func GetSingleIPAddress(addrStr string) (net.IP, error)

IGetSingleIPAddress find and get ip address of given address string. It return first ip if DNS or /etc/hosts has multiple IPs, or return err if no ip is found or addrStr is malformed.

func IsPublicAddr

func IsPublicAddr(addrStr string) bool

func IsSameAddress

func IsSameAddress(ip1str, ip2str string) bool

IsSameAddress check two string is same ip address or domain name.

func ResolveHostDomain

func ResolveHostDomain(domainName string) ([]net.IP, error)

ResolveHostDomain look for ip addresses for the domainName. it return ip addresses if found one or more, or return err if not found any ip address

Types

type AddressType

type AddressType int
const (
	AddressTypeError AddressType = iota
	AddressTypeIP
	AddressTypeFQDN
)

AddressType

func CheckAddressType

func CheckAddressType(urlStr string) AddressType

CheckAddressType check type of urlStr; ip, FQDN or malformed string.

Jump to

Keyboard shortcuts

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