Documentation
¶
Overview ¶
Package netset implements types for network connection sets objects and operations. Types defined in this package: IPBlock - captures a set of IP ranges TCPUDPSet - captures sets of protocols (within TCP,UDP only) and ports (source and destination) ICMPSet - captures sets of type,code values for ICMP protocol TransportSet - captures union of elements from TCPUDPSet, ICMPSet EndpointsTrafficSet - captures a set of traffic attribute for tuples of (source IP range, destination IP range, TransportSet)
Index ¶
- Constants
- type CodeSet
- type Details
- type EndpointsTrafficSet
- func (c *EndpointsTrafficSet) Copy() *EndpointsTrafficSet
- func (c *EndpointsTrafficSet) Equal(other *EndpointsTrafficSet) bool
- func (c *EndpointsTrafficSet) Intersect(other *EndpointsTrafficSet) *EndpointsTrafficSet
- func (c *EndpointsTrafficSet) IsEmpty() bool
- func (c *EndpointsTrafficSet) IsSubset(other *EndpointsTrafficSet) bool
- func (c *EndpointsTrafficSet) Partitions() []ds.Triple[*IPBlock, *IPBlock, *TransportSet]
- func (c *EndpointsTrafficSet) String() string
- func (c *EndpointsTrafficSet) Subtract(other *EndpointsTrafficSet) *EndpointsTrafficSet
- func (c *EndpointsTrafficSet) Union(other *EndpointsTrafficSet) *EndpointsTrafficSet
- type ICMPSet
- func (c *ICMPSet) Copy() *ICMPSet
- func (c *ICMPSet) Equal(other *ICMPSet) bool
- func (c *ICMPSet) Hash() int
- func (c *ICMPSet) Intersect(other *ICMPSet) *ICMPSet
- func (c *ICMPSet) IsAll() bool
- func (c *ICMPSet) IsEmpty() bool
- func (c *ICMPSet) IsSubset(other *ICMPSet) bool
- func (c *ICMPSet) Partitions() []ds.Pair[*TypeSet, *CodeSet]
- func (c *ICMPSet) Size() int
- func (c *ICMPSet) String() string
- func (c *ICMPSet) Subtract(other *ICMPSet) *ICMPSet
- func (c *ICMPSet) Union(other *ICMPSet) *ICMPSet
- type IPBlock
- func DisjointIPBlocks(set1, set2 []*IPBlock) []*IPBlock
- func GetCidrAll() *IPBlock
- func GetFirstIPAddress() *IPBlock
- func GetLastIPAddress() *IPBlock
- func IPBlockFromCidr(cidr string) (*IPBlock, error)
- func IPBlockFromCidrList(cidrsList []string) (*IPBlock, error)
- func IPBlockFromCidrOrAddress(s string) (*IPBlock, error)
- func IPBlockFromIPAddress(ipAddress string) (*IPBlock, error)
- func IPBlockFromIPRange(startIP, endIP *IPBlock) (*IPBlock, error)
- func IPBlockFromIPRangeStr(ipRangeStr string) (*IPBlock, error)
- func NewIPBlock() *IPBlock
- func PairCIDRsToIPBlocks(cidr1, cidr2 string) (ipb1, ipb2 *IPBlock, err error)
- func (b *IPBlock) AsCidr() (string, error)
- func (b *IPBlock) Compare(other *IPBlock) int
- func (b *IPBlock) Copy() *IPBlock
- func (b *IPBlock) Equal(c *IPBlock) bool
- func (b *IPBlock) ExceptCidrs(exceptions ...string) (*IPBlock, error)
- func (b *IPBlock) FirstIPAddress() string
- func (b *IPBlock) FirstIPAddressObject() *IPBlock
- func (b *IPBlock) Hash() int
- func (b *IPBlock) Intersect(c *IPBlock) *IPBlock
- func (b *IPBlock) IsEmpty() bool
- func (b *IPBlock) IsSingleIPAddress() bool
- func (b *IPBlock) IsSubset(other *IPBlock) bool
- func (b *IPBlock) LastIPAddress() string
- func (b *IPBlock) LastIPAddressObject() *IPBlock
- func (b *IPBlock) ListToPrint() []string
- func (b *IPBlock) NextIP() (*IPBlock, error)
- func (b *IPBlock) Overlap(c *IPBlock) bool
- func (b *IPBlock) PrefixLength() (int64, error)
- func (b *IPBlock) PreviousIP() (*IPBlock, error)
- func (b *IPBlock) Size() int
- func (b *IPBlock) Split() []*IPBlock
- func (b *IPBlock) SplitToCidrs() []*IPBlock
- func (b *IPBlock) String() string
- func (b *IPBlock) Subtract(c *IPBlock) *IPBlock
- func (b *IPBlock) ToCidrList() []string
- func (b *IPBlock) ToCidrListString() string
- func (b *IPBlock) ToIPAddressString() string
- func (b *IPBlock) ToIPRanges() string
- func (b *IPBlock) TouchingIPRanges(other *IPBlock) (bool, error)
- func (b *IPBlock) Union(c *IPBlock) *IPBlock
- type PortSet
- type ProtocolSet
- type RFCICMPSet
- func (s *RFCICMPSet) Contains(i int) bool
- func (s *RFCICMPSet) Copy() *RFCICMPSet
- func (s *RFCICMPSet) Equal(other *RFCICMPSet) bool
- func (s *RFCICMPSet) Hash() int
- func (s *RFCICMPSet) Intersect(other *RFCICMPSet) *RFCICMPSet
- func (s *RFCICMPSet) IsAll() bool
- func (s *RFCICMPSet) IsEmpty() bool
- func (s *RFCICMPSet) IsSubset(other *RFCICMPSet) bool
- func (s *RFCICMPSet) Partitions() []netp.ICMP
- func (s *RFCICMPSet) Size() int
- func (s *RFCICMPSet) String() string
- func (s *RFCICMPSet) Subtract(other *RFCICMPSet) *RFCICMPSet
- func (s *RFCICMPSet) Union(other *RFCICMPSet) *RFCICMPSet
- type TCPUDPSet
- func (c *TCPUDPSet) Copy() *TCPUDPSet
- func (c *TCPUDPSet) Equal(other *TCPUDPSet) bool
- func (c *TCPUDPSet) Hash() int
- func (c *TCPUDPSet) Intersect(other *TCPUDPSet) *TCPUDPSet
- func (c *TCPUDPSet) IsAll() bool
- func (c *TCPUDPSet) IsEmpty() bool
- func (c *TCPUDPSet) IsSubset(other *TCPUDPSet) bool
- func (c *TCPUDPSet) Partitions() []ds.Triple[*ProtocolSet, *PortSet, *PortSet]
- func (c *TCPUDPSet) Size() int
- func (c *TCPUDPSet) String() string
- func (c *TCPUDPSet) Subtract(other *TCPUDPSet) *TCPUDPSet
- func (c *TCPUDPSet) SwapPorts() *TCPUDPSet
- func (c *TCPUDPSet) Union(other *TCPUDPSet) *TCPUDPSet
- type TransportSet
- func AllICMPTransport() *TransportSet
- func AllOrNothingTransport(allTcpudp, allIcmp bool) *TransportSet
- func AllTCPTransport() *TransportSet
- func AllTCPorUDPTransport(protocol netp.ProtocolString) *TransportSet
- func AllTransports() *TransportSet
- func AllUDPTransport() *TransportSet
- func NewICMPTransport(minType, maxType, minCode, maxCode int64) *TransportSet
- func NewICMPTransportFromICMPSet(icmpSet *ICMPSet) *TransportSet
- func NewTCPTransport(srcMinP, srcMaxP, dstMinP, dstMaxP int64) *TransportSet
- func NewTCPUDPTransportFromTCPUDPSet(tcpudpSet *TCPUDPSet) *TransportSet
- func NewTCPorUDPTransport(protocol netp.ProtocolString, srcMinP, srcMaxP, dstMinP, dstMaxP int64) *TransportSet
- func NewUDPTransport(srcMinP, srcMaxP, dstMinP, dstMaxP int64) *TransportSet
- func NoTransports() *TransportSet
- func (t *TransportSet) Copy() *TransportSet
- func (t *TransportSet) Equal(other *TransportSet) bool
- func (t *TransportSet) Hash() int
- func (t *TransportSet) ICMPSet() *ICMPSet
- func (t *TransportSet) Intersect(other *TransportSet) *TransportSet
- func (t *TransportSet) IsAll() bool
- func (t *TransportSet) IsEmpty() bool
- func (t *TransportSet) IsSubset(other *TransportSet) bool
- func (t *TransportSet) Size() int
- func (t *TransportSet) String() string
- func (t *TransportSet) Subtract(other *TransportSet) *TransportSet
- func (t *TransportSet) SwapPorts() *TransportSet
- func (t *TransportSet) TCPUDPSet() *TCPUDPSet
- func (t *TransportSet) Union(other *TransportSet) *TransportSet
- type TypeSet
Constants ¶
const ( // CidrAll represents the CIDR for all addresses "0.0.0.0/0" CidrAll = "0.0.0.0/0" FirstIPAddressString = "0.0.0.0" LastIPAddressString = "255.255.255.255" )
const ( AllConnections = "All Connections" NoConnections = "No Connections" )
const ( TCPCode = 0 UDPCode = 1 )
encoding TCP/UDP protocols as integers for TCPUDPSet
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CodeSet ¶
type CodeSet = interval.CanonicalSet
func AllICMPCodes ¶
func AllICMPCodes() *CodeSet
type Details ¶
type Details spec.ProtocolList
func ToJSON ¶
func ToJSON(c *TransportSet) Details
ToJSON returns a `Details` object for JSON representation of the input connection Set.
type EndpointsTrafficSet ¶
type EndpointsTrafficSet struct {
// contains filtered or unexported fields
}
EndpointsTrafficSet captures a set of traffic attributes for tuples of (source IP range, desination IP range, TransportSet), where TransportSet is a set of TCP/UPD/ICMP with their properties (src,dst ports / icmp type,code)
func EmptyEndpointsTrafficSet ¶
func EmptyEndpointsTrafficSet() *EndpointsTrafficSet
EmptyEndpointsTrafficSet returns an empty EndpointsTrafficSet
func NewEndpointsTrafficSet ¶
func NewEndpointsTrafficSet(src, dst *IPBlock, conn *TransportSet) *EndpointsTrafficSet
NewEndpointsTrafficSet returns a new EndpointsTrafficSet object from input src, dst IP-ranges sets ands TransportSet connections
func (*EndpointsTrafficSet) Copy ¶
func (c *EndpointsTrafficSet) Copy() *EndpointsTrafficSet
Copy returns new EndpointsTrafficSet object with same set of connections as current one
func (*EndpointsTrafficSet) Equal ¶
func (c *EndpointsTrafficSet) Equal(other *EndpointsTrafficSet) bool
Equal returns true is this EndpointsTrafficSet captures the exact same set of connections as `other` does.
func (*EndpointsTrafficSet) Intersect ¶
func (c *EndpointsTrafficSet) Intersect(other *EndpointsTrafficSet) *EndpointsTrafficSet
Intersect returns a EndpointsTrafficSet object with connection tuples that result from intersection of this and `other` sets
func (*EndpointsTrafficSet) IsEmpty ¶
func (c *EndpointsTrafficSet) IsEmpty() bool
IsEmpty returns true of the EndpointsTrafficSet is empty
func (*EndpointsTrafficSet) IsSubset ¶
func (c *EndpointsTrafficSet) IsSubset(other *EndpointsTrafficSet) bool
IsSubset returns true if c is subset of other
func (*EndpointsTrafficSet) Partitions ¶
func (c *EndpointsTrafficSet) Partitions() []ds.Triple[*IPBlock, *IPBlock, *TransportSet]
func (*EndpointsTrafficSet) String ¶
func (c *EndpointsTrafficSet) String() string
func (*EndpointsTrafficSet) Subtract ¶
func (c *EndpointsTrafficSet) Subtract(other *EndpointsTrafficSet) *EndpointsTrafficSet
Subtract returns a EndpointsTrafficSet object with connection tuples that result from subtraction of `other` from this set
func (*EndpointsTrafficSet) Union ¶
func (c *EndpointsTrafficSet) Union(other *EndpointsTrafficSet) *EndpointsTrafficSet
Union returns a EndpointsTrafficSet object with connection tuples that result from union of this and `other` sets
type ICMPSet ¶
type ICMPSet struct {
// contains filtered or unexported fields
}
func AllICMPSet ¶
func AllICMPSet() *ICMPSet
func EmptyICMPSet ¶
func EmptyICMPSet() *ICMPSet
func ICMPSetFromICMP ¶ added in v0.5.5
func NewICMPSet ¶
type IPBlock ¶
type IPBlock struct {
// contains filtered or unexported fields
}
IPBlock captures a set of IP ranges
func DisjointIPBlocks ¶
DisjointIPBlocks returns an IPBlock of disjoint ip ranges from 2 input IPBlock objects
func GetCidrAll ¶
func GetCidrAll() *IPBlock
GetCidrAll returns IPBlock object of the entire range 0.0.0.0/0
func GetFirstIPAddress ¶ added in v0.5.1
func GetFirstIPAddress() *IPBlock
GetFirstIPAddress returns IPBlock object of 0.0.0.0
func GetLastIPAddress ¶ added in v0.5.1
func GetLastIPAddress() *IPBlock
GetLastIPAddress returns IPBlock object of 255.255.255.255
func IPBlockFromCidr ¶
IPBlockFromCidr returns a new IPBlock object from input CIDR string
func IPBlockFromCidrList ¶
IPBlockFromCidrList returns IPBlock object from multiple CIDRs given as list of strings
func IPBlockFromCidrOrAddress ¶
IPBlockFromCidrOrAddress returns a new IPBlock object from input string of CIDR or IP address
func IPBlockFromIPAddress ¶
IPBlockFromIPAddress returns an IPBlock object from input IP address string
func IPBlockFromIPRange ¶ added in v0.5.1
IPBlockFromIPRange returns a new IPBlock object that contains startIP-endIP
func IPBlockFromIPRangeStr ¶
IPBlockFromIPRangeStr returns IPBlock object from input IP range string (example: "169.255.0.0-172.15.255.255")
func PairCIDRsToIPBlocks ¶
PairCIDRsToIPBlocks returns two IPBlock objects from two input CIDR strings
func (*IPBlock) AsCidr ¶ added in v0.5.2
AsCidr returns the CIDR string of this IPBlock object, if it contains exactly one CIDR, otherwise it returns an error
func (*IPBlock) ExceptCidrs ¶
ExceptCidrs returns a new IPBlock with all cidr ranges removed
func (*IPBlock) FirstIPAddress ¶
FirstIPAddress returns the first IP Address string for this IPBlock
func (*IPBlock) FirstIPAddressObject ¶ added in v0.5.1
FirstIPAddressObject returns the first IP Address for this IPBlock
func (*IPBlock) Intersect ¶
Intersect returns a new IPBlock from intersection of this IPBlock with input IPBlock
func (*IPBlock) IsSingleIPAddress ¶ added in v0.5.1
IsSingleIPAddress returns true if this ipblock is a single IP address
func (*IPBlock) LastIPAddress ¶ added in v0.5.1
LastIPAddress returns the last IP Address string for this IPBlock
func (*IPBlock) LastIPAddressObject ¶ added in v0.5.1
LastIPAddressObject returns the last IP Address for this IPBlock
func (*IPBlock) ListToPrint ¶
ListToPrint returns a uniform to print list s.t. each element contains either a single cidr or an ip range
func (*IPBlock) Overlap ¶
Overlap returns whether the two IPBlocks have at least one IP address in common
func (*IPBlock) PrefixLength ¶
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) PreviousIP ¶ added in v0.5.1
PreviousIP returns the previous ip address before this IPBlock
func (*IPBlock) SplitToCidrs ¶ added in v0.5.1
SplitToCidrs returns a slice of IPBlocks, each representing a single CIDR
func (*IPBlock) String ¶
String returns an IPBlock's string -- either single IP address, or list of CIDR strings
func (*IPBlock) Subtract ¶
Subtract returns a new IPBlock from subtraction of input IPBlock from this IPBlock
func (*IPBlock) ToCidrList ¶
ToCidrList returns a list of CIDR strings for this IPBlock object
func (*IPBlock) ToCidrListString ¶
ToCidrListString returns a string with all CIDRs within the IPBlock object
func (*IPBlock) ToIPAddressString ¶
ToIPAddressString returns the IP Address string for this IPBlock
func (*IPBlock) ToIPRanges ¶
ToIPRanges returns a string of the ip ranges in the current IPBlock object
func (*IPBlock) TouchingIPRanges ¶ added in v0.5.1
TouchingIPRanges returns true if this and other ipblocks objects are touching. assumption: both IPBlocks represent a single IP range
type PortSet ¶
type PortSet = interval.CanonicalSet // valid range: [1,65535] (see netp.MinPort , netp.MaxPort)
type ProtocolSet ¶
type ProtocolSet = interval.CanonicalSet // valid range: [0,1] (see TCPCode , UDPCode)
func AllTCPUDPProtocolSet ¶
func AllTCPUDPProtocolSet() *ProtocolSet
type RFCICMPSet ¶
type RFCICMPSet uint32
RFCICMPSet is a set of _valid_ (by RFC) ICMP values, encoded as a bitset
func AllICMPSetStrict ¶
func AllICMPSetStrict() *RFCICMPSet
func EmptyICMPSetStrict ¶
func EmptyICMPSetStrict() *RFCICMPSet
func NewICMPSetStrict ¶
func NewICMPSetStrict(t netp.ICMP) *RFCICMPSet
func (*RFCICMPSet) Contains ¶
func (s *RFCICMPSet) Contains(i int) bool
func (*RFCICMPSet) Copy ¶
func (s *RFCICMPSet) Copy() *RFCICMPSet
func (*RFCICMPSet) Equal ¶
func (s *RFCICMPSet) Equal(other *RFCICMPSet) bool
func (*RFCICMPSet) Hash ¶
func (s *RFCICMPSet) Hash() int
func (*RFCICMPSet) Intersect ¶
func (s *RFCICMPSet) Intersect(other *RFCICMPSet) *RFCICMPSet
func (*RFCICMPSet) IsAll ¶
func (s *RFCICMPSet) IsAll() bool
func (*RFCICMPSet) IsEmpty ¶
func (s *RFCICMPSet) IsEmpty() bool
func (*RFCICMPSet) IsSubset ¶
func (s *RFCICMPSet) IsSubset(other *RFCICMPSet) bool
func (*RFCICMPSet) Partitions ¶
func (s *RFCICMPSet) Partitions() []netp.ICMP
Partitions returns a list of ICMP values. if all codes for a given type are present, it adds a single ICMP value with nil Code. If all ICMP values are present, a single ICMP value with nil TypeCode is returned.
func (*RFCICMPSet) Size ¶
func (s *RFCICMPSet) Size() int
func (*RFCICMPSet) String ¶
func (s *RFCICMPSet) String() string
func (*RFCICMPSet) Subtract ¶
func (s *RFCICMPSet) Subtract(other *RFCICMPSet) *RFCICMPSet
func (*RFCICMPSet) Union ¶
func (s *RFCICMPSet) Union(other *RFCICMPSet) *RFCICMPSet
type TCPUDPSet ¶
type TCPUDPSet struct {
// contains filtered or unexported fields
}
TCPUDPSet captures sets of protocols (within TCP,UDP only) and ports (source and destination)
func AllTCPUDPSet ¶
func AllTCPUDPSet() *TCPUDPSet
func EmptyTCPorUDPSet ¶
func EmptyTCPorUDPSet() *TCPUDPSet
func NewAllTCPOnlySet ¶
func NewAllTCPOnlySet() *TCPUDPSet
func NewAllUDPOnlySet ¶
func NewAllUDPOnlySet() *TCPUDPSet
func NewTCPorUDPSet ¶
func NewTCPorUDPSet(protocolString netp.ProtocolString, srcMinP, srcMaxP, dstMinP, dstMaxP int64) *TCPUDPSet
func (*TCPUDPSet) Partitions ¶
type TransportSet ¶
type TransportSet struct {
// contains filtered or unexported fields
}
TransportSet captures connection-sets for protocols from {TCP, UDP, ICMP}
func AllICMPTransport ¶
func AllICMPTransport() *TransportSet
func AllOrNothingTransport ¶
func AllOrNothingTransport(allTcpudp, allIcmp bool) *TransportSet
func AllTCPTransport ¶
func AllTCPTransport() *TransportSet
AllTCPTransport returns a set of connections containing the TCP protocol with all its possible ports
func AllTCPorUDPTransport ¶
func AllTCPorUDPTransport(protocol netp.ProtocolString) *TransportSet
func AllTransports ¶
func AllTransports() *TransportSet
func AllUDPTransport ¶
func AllUDPTransport() *TransportSet
AllUDPTransport returns a set of connections containing the UDP protocol with all its possible ports
func NewICMPTransport ¶
func NewICMPTransport(minType, maxType, minCode, maxCode int64) *TransportSet
func NewICMPTransportFromICMPSet ¶ added in v0.5.5
func NewICMPTransportFromICMPSet(icmpSet *ICMPSet) *TransportSet
func NewTCPTransport ¶
func NewTCPTransport(srcMinP, srcMaxP, dstMinP, dstMaxP int64) *TransportSet
NewTCP returns a set of TCP connections containing the specified ports
func NewTCPUDPTransportFromTCPUDPSet ¶ added in v0.5.5
func NewTCPUDPTransportFromTCPUDPSet(tcpudpSet *TCPUDPSet) *TransportSet
func NewTCPorUDPTransport ¶
func NewTCPorUDPTransport(protocol netp.ProtocolString, srcMinP, srcMaxP, dstMinP, dstMaxP int64) *TransportSet
func NewUDPTransport ¶
func NewUDPTransport(srcMinP, srcMaxP, dstMinP, dstMaxP int64) *TransportSet
func NoTransports ¶
func NoTransports() *TransportSet
func (*TransportSet) Copy ¶
func (t *TransportSet) Copy() *TransportSet
func (*TransportSet) Equal ¶
func (t *TransportSet) Equal(other *TransportSet) bool
func (*TransportSet) Hash ¶
func (t *TransportSet) Hash() int
func (*TransportSet) ICMPSet ¶
func (t *TransportSet) ICMPSet() *ICMPSet
func (*TransportSet) Intersect ¶
func (t *TransportSet) Intersect(other *TransportSet) *TransportSet
func (*TransportSet) IsAll ¶
func (t *TransportSet) IsAll() bool
func (*TransportSet) IsEmpty ¶
func (t *TransportSet) IsEmpty() bool
func (*TransportSet) IsSubset ¶
func (t *TransportSet) IsSubset(other *TransportSet) bool
IsSubset returns true if c is subset of other
func (*TransportSet) Size ¶
func (t *TransportSet) Size() int
func (*TransportSet) String ¶
func (t *TransportSet) String() string
func (*TransportSet) Subtract ¶
func (t *TransportSet) Subtract(other *TransportSet) *TransportSet
func (*TransportSet) SwapPorts ¶
func (t *TransportSet) SwapPorts() *TransportSet
func (*TransportSet) TCPUDPSet ¶
func (t *TransportSet) TCPUDPSet() *TCPUDPSet
func (*TransportSet) Union ¶
func (t *TransportSet) Union(other *TransportSet) *TransportSet
type TypeSet ¶
type TypeSet = interval.CanonicalSet
func AllICMPTypes ¶
func AllICMPTypes() *TypeSet