net

package
v1.7.2 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2017 License: Apache-2.0 Imports: 2 Imported by: 24

Documentation

Overview

Package net implements a set of net types that are extensions to the built-in net package. The extensions provide additional function such as JSON marshaling and unmarshaling.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseCIDR

func ParseCIDR(c string) (*IP, *IPNet, error)

Types

type IP

type IP struct {
	net.IP
}

Sub class net.IP so that we can add JSON marshalling and unmarshalling.

func MustParseIP added in v1.5.0

func MustParseIP(i string) IP

MustParseIP parses the string into a IP.

func ParseIP added in v1.2.0

func ParseIP(ip string) *IP

ParseIP returns an IP from a string

func (IP) MarshalJSON

func (i IP) MarshalJSON() ([]byte, error)

MarshalJSON interface for an IP

func (*IP) Network added in v1.1.0

func (i *IP) Network() *IPNet

Network returns the IP address as a fully masked IPNet type.

func (*IP) UnmarshalJSON

func (i *IP) UnmarshalJSON(b []byte) error

UnmarshalJSON interface for an IP

func (IP) Version

func (i IP) Version() int

Version returns the IP version for an IP, or 0 if the IP is not valid.

type IPNet

type IPNet struct {
	net.IPNet
}

Sub class net.IPNet so that we can add JSON marshalling and unmarshalling.

func MustParseCIDR added in v1.5.0

func MustParseCIDR(c string) IPNet

MustParseCIDR parses the string into a IPNet. The IP address in the IPNet is not masked.

func MustParseNetwork added in v1.5.0

func MustParseNetwork(c string) IPNet

MustParseNetwork parses the string into a IPNet. The IP address in the IPNet is masked.

func (IPNet) IsNetOverlap added in v1.2.0

func (i IPNet) IsNetOverlap(n net.IPNet) bool

IsNetOverlap is a utility function that returns true if the two subnet have an overlap.

func (IPNet) MarshalJSON

func (i IPNet) MarshalJSON() ([]byte, error)

MarshalJSON interface for an IPNet

func (*IPNet) Network added in v1.1.0

func (i *IPNet) Network() *IPNet

Network returns the masked IP network.

func (IPNet) String

func (i IPNet) String() string

String returns a friendly name for the network. The standard net package implements String() on the pointer, which means it will not be invoked on a struct type, so we re-implement on the struct type.

func (*IPNet) UnmarshalJSON

func (i *IPNet) UnmarshalJSON(b []byte) error

UnmarshalJSON interface for an IPNet

func (*IPNet) Version

func (i *IPNet) Version() int

Version returns the IP version for an IPNet, or 0 if not a valid IP net.

type MAC

type MAC struct {
	net.HardwareAddr
}

Sub class net.HardwareAddr so that we can add JSON marshalling and unmarshalling.

func (MAC) MarshalJSON

func (m MAC) MarshalJSON() ([]byte, error)

MarshalJSON interface for a MAC

func (*MAC) UnmarshalJSON

func (m *MAC) UnmarshalJSON(b []byte) error

UnmarshalJSON interface for a MAC

Jump to

Keyboard shortcuts

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