iputil

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2023 License: MIT Imports: 13 Imported by: 0

README

iputil

The package contains various helpers to interact with ips and cidrs

Documentation

Index

Constants

View Source
const ExtendIPDefaultPort = "80"

Variables

This section is empty.

Functions

func AsIPV4CIDR

func AsIPV4CIDR(IPV4 string) string

AsIPV4CIDR converts ipv4 ip to cidr string

func AsIPV4IpNet

func AsIPV4IpNet(IPV4 string) *net.IPNet

AsIPV4CIDR converts ipv4 cidr to net.IPNet pointer

func AsIPV6CIDR

func AsIPV6CIDR(IPV6 string) string

AsIPV4CIDR converts ipv6 ip to cidr string

func AsIPV6IpNet

func AsIPV6IpNet(IPV6 string) *net.IPNet

AsIPV6IpNet converts ipv6 cidr to net.IPNet pointer

func CanExtend added in v1.0.4

func CanExtend(hosts ...string) bool

CanExtend determines if the provided hosts (ip,short ip, hostname) can be extended to ip

func GetBindableAddress

func GetBindableAddress(port int, ips ...string) (string, error)

GetBindableAddress on port p from a list of ips

func GetSourceIP

func GetSourceIP(target string) (net.IP, error)

GetSourceIP gets the local ip based the destination ip

func IsCIDR

func IsCIDR(str string) bool

IsCIDR checks if the string is an valid CIDR notiation (IPV4 & IPV6)

func IsCidrWithExpansion

func IsCidrWithExpansion(str string) bool

IsCIDR checks if the string is an valid CIDR after replacing - with /

func IsIP

func IsIP(str string) bool

IsIP checks if a string is either IP version 4 or 6. Alias for `net.ParseIP`

func IsIPv4

func IsIPv4(ips ...interface{}) bool

IsIPv4 checks if the string is an IP version 4.

func IsIPv6

func IsIPv6(ips ...interface{}) bool

IsIPv6 checks if the string is an IP version 6.

func IsInIpv4List

func IsInIpv4List(str string) bool

Check if an IP address is part of the list of internal IPs we have declared

func IsInIpv6List

func IsInIpv6List(str string) bool

Check if an IP address is part of the list of internal IPs we have declared

func IsInternal

func IsInternal(str string) bool

Check if an IP address is part of the list of internal IPs we have declared checks for all ipv4 and ipv6 list

func IsPort

func IsPort(str string) bool

IsPort checks if a string represents a valid port

func ToCidr

func ToCidr(item string) *net.IPNet

ToCidr converts a cidr string to net.IPNet pointer

func ToFQDN

func ToFQDN(target string) ([]string, error)

ToFQDN performs a reverse PTR using default system resolvers

func TryExtendIP added in v1.0.4

func TryExtendIP(host string) (net.IP, error)

TryRealIP attemps to extend a host (ip, short ip, hostname) to its extended ip version

func WhatsMyIP

func WhatsMyIP() (string, error)

WhatsMyIP attempts to obtain the external ip through public api

Types

This section is empty.

Jump to

Keyboard shortcuts

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