ipblock

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Copyright 2023- IBM Inc. All Rights Reserved.

SPDX-License-Identifier: Apache-2.0

Index

Constants

View Source
const (
	// CidrAll represents the CIDR for all addresses "0.0.0.0/0"
	CidrAll = "0.0.0.0/0"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type IPBlock

type IPBlock struct {
	// contains filtered or unexported fields
}

IPBlock captures a set of IP ranges

func DisjointIPBlocks

func DisjointIPBlocks(set1, set2 []*IPBlock) []*IPBlock

DisjointIPBlocks returns an IPBlock of disjoint ip ranges from 2 input IPBlock objects

func FromCidr

func FromCidr(cidr string) (*IPBlock, error)

FromCidr returns a new IPBlock object from input CIDR string

func FromCidrList

func FromCidrList(cidrsList []string) (*IPBlock, error)

FromCidrList returns IPBlock object from multiple CIDRs given as list of strings

func FromCidrOrAddress

func FromCidrOrAddress(s string) (*IPBlock, error)

FromCidrOrAddress returns a new IPBlock object from input string of CIDR or IP address

func FromIPAddress

func FromIPAddress(ipAddress string) (*IPBlock, error)

FromIPAddress returns an IPBlock object from input IP address string

func FromIPRangeStr

func FromIPRangeStr(ipRangeStr string) (*IPBlock, error)

FromIPRangeStr returns IPBlock object from input IP range string (example: "169.255.0.0-172.15.255.255")

func GetCidrAll

func GetCidrAll() *IPBlock

GetCidrAll returns IPBlock object of the entire range 0.0.0.0/0

func New

func New() *IPBlock

New returns a new IPBlock object

func PairCIDRsToIPBlocks

func PairCIDRsToIPBlocks(cidr1, cidr2 string) (ipb1, ipb2 *IPBlock, err error)

PairCIDRsToIPBlocks returns two IPBlock objects from two input CIDR strings

func (*IPBlock) ContainedIn

func (b *IPBlock) ContainedIn(other *IPBlock) bool

ContainedIn checks if this IP block is contained within another IP block.

func (*IPBlock) Copy

func (b *IPBlock) Copy() *IPBlock

Copy returns a new copy of IPBlock object

func (*IPBlock) Equal

func (b *IPBlock) Equal(c *IPBlock) bool

Equal returns true if this IPBlock equals the input IPBlock

func (*IPBlock) ExceptCidrs added in v0.3.0

func (b *IPBlock) ExceptCidrs(exceptions ...string) (*IPBlock, error)

ExceptCidrs returns a new IPBlock with all cidr ranges removed

func (*IPBlock) FirstIPAddress added in v0.3.2

func (b *IPBlock) FirstIPAddress() string

FirstIPAddress() returns the first IP Address string for this IPBlock

func (*IPBlock) Intersect

func (b *IPBlock) Intersect(c *IPBlock) *IPBlock

Intersect returns a new IPBlock from intersection of this IPBlock with input IPBlock

func (*IPBlock) IsEmpty

func (b *IPBlock) IsEmpty() bool

IsEmpty returns true if this IPBlock is empty

func (*IPBlock) ListToPrint

func (b *IPBlock) ListToPrint() []string

ListToPrint: returns a uniform to print list s.t. each element contains either a single cidr or an ip range

func (*IPBlock) Overlap added in v0.3.4

func (b *IPBlock) Overlap(c *IPBlock) bool

Overlap returns whether the two IPBlocks have at least one IP address in common

func (*IPBlock) PrefixLength

func (b *IPBlock) PrefixLength() (int64, error)

PrefixLength returns the cidr's prefix length, assuming the ipBlock is exactly one cidr. Prefix length specifies the number of bits in the IP address that are to be used as the subnet mask.

func (*IPBlock) Split

func (b *IPBlock) Split() []*IPBlock

Split returns a set of IpBlock objects, each with a single range of ips

func (*IPBlock) String added in v0.3.1

func (b *IPBlock) String() string

String returns an IPBlock's string -- either single IP address, or list of CIDR strings

func (*IPBlock) Subtract

func (b *IPBlock) Subtract(c *IPBlock) *IPBlock

Subtract returns a new IPBlock from subtraction of input IPBlock from this IPBlock

func (*IPBlock) ToCidrList

func (b *IPBlock) ToCidrList() []string

ToCidrList returns a list of CIDR strings for this IPBlock object

func (*IPBlock) ToCidrListString

func (b *IPBlock) ToCidrListString() string

ToCidrListString returns a string with all CIDRs within the IPBlock object

func (*IPBlock) ToIPAddressString

func (b *IPBlock) ToIPAddressString() string

ToIPAdressString returns the IP Address string for this IPBlock

func (*IPBlock) ToIPRanges

func (b *IPBlock) ToIPRanges() string

ToIPRanges returns a string of the ip ranges in the current IPBlock object

func (*IPBlock) Union

func (b *IPBlock) Union(c *IPBlock) *IPBlock

Union returns a new IPBlock from union of input IPBlock with this IPBlock

Jump to

Keyboard shortcuts

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