net

package module
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: May 10, 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 DomainToPunycode added in v1.0.3

func DomainToPunycode(domainname string) (string, error)

DomainToPunycode returns normalised domain name as Punycode

func DomainToUnicode added in v1.0.3

func DomainToUnicode(domainname string) (string, error)

DomainToUnicode returns domain name as Unicode

func FQDNToPunycode added in v1.0.3

func FQDNToPunycode(fqdn string) (string, error)

FQDNToPunycode returns domain name as Punycode

func FQDNToUnicode added in v1.0.3

func FQDNToUnicode(fqdn string) (string, error)

FQDNToUnicode returns domain name as Unicode

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 NormaliseIPAddr

func NormaliseIPAddr(ip string) string

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

func NormaliseURL added in v1.0.3

func NormaliseURL(u string) (string, error)

func ReverseIPAddr

func ReverseIPAddr(ip string) (string, error)

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

func URLToPunycode added in v1.0.3

func URLToPunycode(u string) (string, error)

URLToPunycode returns URL string in punycode

func URLToUnicode added in v1.0.3

func URLToUnicode(u string) (string, error)

NormaliseURLToUnicode returns normalised URL string.

Types

This section is empty.

Jump to

Keyboard shortcuts

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