net

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 7, 2021 License: MIT Imports: 10 Imported by: 6

README

go-net

Introduction

This library contains some basic validation and helpers for handling ip addresses (IPv4 + IPv6), ip ranges (from - to ip adress, IPv4 + IPv6), domain names, fqdn (fully qualified domain names), and urls.

Please see the unit tests (xx_test.go) for examples.

License

Release under the MIT License. (see LICENSE)

Codacy Badge

Documentation

Overview

Package net contains helper function for handling e.g. ip addresses or domain names

Package net contains helper function for handling e.g. ip addresses or domain names

Package net contains helper function for handling e.g. ip addresses or domain names

Package net contains helper function for handling e.g. ip addresses or domain names

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DomainFromFqdn

func DomainFromFqdn(fqdn string) string

DomainFromFqdn returns domain name or empty string

func HostFromURL

func HostFromURL(u string) (string, error)

HostFromURL extraxts hostname from given URL

func IntToIP

func IntToIP(i string) net.IP

IntToIP (int) return net.IP from the integer representation of an ip address (use e.g. for IP2Location databases )

func IsDomain

func IsDomain(domainname string) bool

IsDomain (domainname string) returns true is domainname is a valid domain, otherwise false

func IsFQDN

func IsFQDN(fqdn string) bool

IsFQDN (fqdn) returns true if fqdn is a FQDN (Fully Qualified Domain Name) hostname + domainname + tld, otherwise false

func IsIPAddr

func IsIPAddr(ip string) bool

IsIPAddr return true if string ip contains a valid representation of an IPv4 or IPv6 address

func IsIPRange

func IsIPRange(r string) bool

IsIPRange (range) return true if string r contains a valid representation of an ip network (e.g. 192.168.10.1-192.168.10.199)

func IsIPv4

func IsIPv4(ip net.IP) bool

IsIPv4 (ipaddr) return true if string ip contains a valid representation of an IPv4 address

func IsIPv6

func IsIPv6(ip net.IP) bool

IsIPv6 (ipaddr) return true if string ip contains a valid representation of an IPv6 address

func IsNetwork

func IsNetwork(network string) bool

IsNetwork (network) return true if string network contains a valid representation of an ip network

func IsURL

func IsURL(u string) bool

IsURL returns true if string represents a valid URL

func NormaliseDomainToPunycode

func NormaliseDomainToPunycode(domainname string) (string, error)

NormaliseDomainToPunycode returns normalised domain name as Punycode

func NormaliseDomainToUnicode

func NormaliseDomainToUnicode(domainname string) (string, error)

NormaliseDomainToUnicode returns normalised domain name as Unicode

func NormaliseFQDNToPunycode

func NormaliseFQDNToPunycode(fqdn string) (string, error)

NormaliseFQDNToPunycode returns normalised domain name as Punycode

func NormaliseFQDNToUnicode

func NormaliseFQDNToUnicode(fqdn string) (string, error)

NormaliseFQDNToUnicode returns normalised domain name as Unicode

func NormaliseIPAddr

func NormaliseIPAddr(ip string) string

NormaliseIPAddr return ip adresse without /32 (IPv4 or /128 (IPv6)

func NormaliseURLToPunycode

func NormaliseURLToPunycode(u string) (string, error)

NormaliseURLToPunycode returns normalised URL string.

func NormaliseURLToUnicode

func NormaliseURLToUnicode(u string) (string, error)

NormaliseURLToUnicode returns normalised URL string.

func ReverseIPAddr

func ReverseIPAddr(ip string) (string, error)

ReverseIPAddr (ipaddr) reverses string ip (use e.g. for DNS blacklists)

Types

This section is empty.

Jump to

Keyboard shortcuts

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