iputil

package module
v0.0.0-...-17ef68d Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2018 License: BSD-2-Clause Imports: 3 Imported by: 9

README

iputil is a package for simple and useful IP and networking functions

Coverage Status

Documentation

Overview

Package iputil implements some useful functions for manipulating IP addresses

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CIDRToIPNet

func CIDRToIPNet(cidr string) (*net.IPNet, error)

func FirstAddr

func FirstAddr(n *net.IPNet) net.IP

FirstAddr returns the first address in an IPNet, usually the network address

func IPAdd

func IPAdd(ip net.IP, offset int) net.IP

IPAdd adds an offset to an IP

func IPBefore

func IPBefore(ip, ip2 net.IP) bool

IPBefore returns true if ip < ip2

func IPDiff

func IPDiff(ip, ip2 net.IP) int

IPDiff returns the difference between ip and ip2 nil is treated as the zero address

func LastAddr

func LastAddr(n *net.IPNet) net.IP

LastAddr returns the last address in an IPNet, usually the broadcast address

func NetworkID

func NetworkID(n *net.IPNet) *net.IPNet

NetworkID returns an IPNet representing the network, based on an IPNet of any IP in a network

func RandAddr

func RandAddr(n *net.IPNet) net.IP

RandAddr generates a reandom address in an IPNet

func RandAddrWithExclude

func RandAddrWithExclude(n *net.IPNet, xf, xl int) net.IP

RandAddrWithExclude Generates a random address in an IPNet, excluding the first xf and last xl addresses. To generate a random address, excluding the network and broadcast addresses use 1 for xf and xl

func SubnetContainsSubnet

func SubnetContainsSubnet(supernet, subnet *net.IPNet) bool

SubnetContainsSubnet returns true if the first subnet contains the second nil is considered to be a global supernet "0.0.0.0/0" or "::/0"

func SubnetEqualSubnet

func SubnetEqualSubnet(net1, net2 *net.IPNet) bool

SubnetEqualSubnet returns true if to IPNets are equal nil is considered to be a global supernet "0.0.0.0/0" or "::/0"

Types

This section is empty.

Jump to

Keyboard shortcuts

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