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 ¶
- func IPToBigInt(ip IP) *big.Int
- func ParseCIDR(c string) (*IP, *IPNet, error)
- func ParseCIDROrIP(c string) (*IP, *IPNet, error)
- type IP
- type IPNet
- func (i IPNet) Covers(n net.IPNet) bool
- func (i IPNet) IsNetOverlap(n net.IPNet) bool
- func (i IPNet) MarshalJSON() ([]byte, error)
- func (i *IPNet) Network() *IPNet
- func (i IPNet) NthIP(n int) IP
- func (i IPNet) NumAddrs() *big.Int
- func (i IPNet) String() string
- func (i *IPNet) UnmarshalJSON(b []byte) error
- func (i *IPNet) Version() int
- type MAC
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IPToBigInt ¶
Types ¶
type IP ¶
Sub class net.IP so that we can add JSON marshalling and unmarshalling.
func (*IP) UnmarshalJSON ¶
UnmarshalJSON interface for an IP
type IPNet ¶
Sub class net.IPNet so that we can add JSON marshalling and unmarshalling.
func MustParseCIDR ¶
MustParseCIDR parses the string into an IPNet. The IP address in the IPNet is not masked.
func MustParseNetwork ¶
MustParseNetwork parses the string into an IPNet. The IP address in the IPNet is masked.
func (IPNet) IsNetOverlap ¶
IsNetOverlap is a utility function that returns true if the two subnet have an overlap.
func (IPNet) MarshalJSON ¶
MarshalJSON interface for an IPNet
func (IPNet) 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 ¶
UnmarshalJSON interface for an IPNet
type MAC ¶
type MAC struct {
net.HardwareAddr
}
Sub class net.HardwareAddr so that we can add JSON marshalling and unmarshalling.
func (*MAC) UnmarshalJSON ¶
UnmarshalJSON interface for a MAC