iputil

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2022 License: MIT Imports: 10 Imported by: 47

README

iputil

The package contains various helpers to interact with ips and cidrs

Documentation

Index

Constants

This section is empty.

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 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 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 WhatsMyIP

func WhatsMyIP() (string, error)

WhatsMyIP attempts to obtain the external ip through public api Copied from https://github.com/projectdiscovery/naabu/blob/master/v2/pkg/scan/externalip.go

Types

This section is empty.

Jump to

Keyboard shortcuts

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