Documentation
¶
Overview ¶
Copyright 2022
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- func InttoIP4(ipInt int64) string
- type CanonicalIntervalSet
- func (c *CanonicalIntervalSet) AddHole(hole Interval)
- func (c *CanonicalIntervalSet) AddInterval(intervalToAdd Interval)
- func (c *CanonicalIntervalSet) ContainedIn(other CanonicalIntervalSet) bool
- func (c *CanonicalIntervalSet) Copy() CanonicalIntervalSet
- func (c *CanonicalIntervalSet) Equal(other CanonicalIntervalSet) bool
- func (c *CanonicalIntervalSet) Intersection(other CanonicalIntervalSet)
- func (c *CanonicalIntervalSet) IsEmpty() bool
- func (c *CanonicalIntervalSet) Overlaps(other *CanonicalIntervalSet) bool
- func (c *CanonicalIntervalSet) String() string
- func (c *CanonicalIntervalSet) Subtraction(other CanonicalIntervalSet)
- func (c *CanonicalIntervalSet) Union(other CanonicalIntervalSet)
- type Connection
- type ConnectionSet
- func (conn *ConnectionSet) AddConnection(protocol v1.Protocol, ports PortSet)
- func (conn *ConnectionSet) AllConnections() bool
- func (conn *ConnectionSet) ContainedIn(other *ConnectionSet) bool
- func (conn *ConnectionSet) Contains(port, protocol string) bool
- func (conn *ConnectionSet) Equal(other *ConnectionSet) bool
- func (conn *ConnectionSet) Intersection(other *ConnectionSet)
- func (conn *ConnectionSet) IsEmpty() bool
- func (conn *ConnectionSet) ProtocolsAndPortsMap() map[v1.Protocol][]PortRange
- func (conn *ConnectionSet) String() string
- func (conn *ConnectionSet) Union(other *ConnectionSet)
- type IPBlock
- type Interval
- type PortRange
- type PortSet
- func (p *PortSet) AddPort(port intstr.IntOrString)
- func (p *PortSet) AddPortRange(minPort, maxPort int64)
- func (p *PortSet) ContainedIn(other PortSet) bool
- func (p *PortSet) Contains(port int64) bool
- func (p *PortSet) Copy() PortSet
- func (p *PortSet) Equal(other PortSet) bool
- func (p *PortSet) Intersection(other PortSet)
- func (p *PortSet) IsAll() bool
- func (p *PortSet) IsEmpty() bool
- func (p *PortSet) RemovePort(port intstr.IntOrString)
- func (p *PortSet) String() string
- func (p *PortSet) Union(other PortSet)
Constants ¶
const ( DefaultFormat = "txt" TextFormat = "txt" JSONFormat = "json" DOTFormat = "dot" CSVFormat = "csv" MDFormat = "md" )
formats supported for output of various commands
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CanonicalIntervalSet ¶
type CanonicalIntervalSet struct {
IntervalSet []Interval // sorted list of non-overlapping intervals
}
CanonicalIntervalSet is a canonical representation of a set of Interval objects
func (*CanonicalIntervalSet) AddHole ¶
func (c *CanonicalIntervalSet) AddHole(hole Interval)
AddHole updates the current CanonicalIntervalSet object by removing the input Interval from the set
func (*CanonicalIntervalSet) AddInterval ¶
func (c *CanonicalIntervalSet) AddInterval(intervalToAdd Interval)
AddInterval updates the current CanonicalIntervalSet with a new Interval to add
func (*CanonicalIntervalSet) ContainedIn ¶
func (c *CanonicalIntervalSet) ContainedIn(other CanonicalIntervalSet) bool
ContainedIn returns true of the current CanonicalIntervalSet is contained in the input CanonicalIntervalSet
func (*CanonicalIntervalSet) Copy ¶
func (c *CanonicalIntervalSet) Copy() CanonicalIntervalSet
Copy returns a new copy of the CanonicalIntervalSet object
func (*CanonicalIntervalSet) Equal ¶
func (c *CanonicalIntervalSet) Equal(other CanonicalIntervalSet) bool
Equal returns true if the CanonicalIntervalSet equals the input CanonicalIntervalSet
func (*CanonicalIntervalSet) Intersection ¶
func (c *CanonicalIntervalSet) Intersection(other CanonicalIntervalSet)
Intersection updates current CanonicalIntervalSet with intersection result of input CanonicalIntervalSet
func (*CanonicalIntervalSet) IsEmpty ¶
func (c *CanonicalIntervalSet) IsEmpty() bool
IsEmpty returns true if the CanonicalIntervalSet is empty
func (*CanonicalIntervalSet) Overlaps ¶
func (c *CanonicalIntervalSet) Overlaps(other *CanonicalIntervalSet) bool
Overlaps returns true if current CanonicalIntervalSet overlaps with input CanonicalIntervalSet
func (*CanonicalIntervalSet) String ¶
func (c *CanonicalIntervalSet) String() string
String returns a string representation of the current CanonicalIntervalSet object
func (*CanonicalIntervalSet) Subtraction ¶
func (c *CanonicalIntervalSet) Subtraction(other CanonicalIntervalSet)
Subtraction updates current CanonicalIntervalSet with subtraction result of input CanonicalIntervalSet
func (*CanonicalIntervalSet) Union ¶
func (c *CanonicalIntervalSet) Union(other CanonicalIntervalSet)
Union updates the CanonicalIntervalSet object with the union result of the input CanonicalIntervalSet
type Connection ¶
type Connection interface { // ProtocolsAndPortsMap returns the set of allowed connections ProtocolsAndPortsMap() map[v1.Protocol][]PortRange // AllConnections returns true if all ports are allowed for all protocols AllConnections() bool // IsEmpty returns true if no connection is allowed IsEmpty() bool }
Connection represents a set of allowed connections between two peers
type ConnectionSet ¶
type ConnectionSet struct { AllowAll bool AllowedProtocols map[v1.Protocol]*PortSet // map from protocol name to set of allowed ports }
ConnectionSet represents a set of allowed connections between two peers on a k8s env and implements Connection interface
func MakeConnectionSet ¶
func MakeConnectionSet(all bool) *ConnectionSet
MakeConnectionSet returns a pointer to ConnectionSet object with all connections or no connections
func (*ConnectionSet) AddConnection ¶
func (conn *ConnectionSet) AddConnection(protocol v1.Protocol, ports PortSet)
AddConnection updates current ConnectionSet object with new allowed connection
func (*ConnectionSet) AllConnections ¶
func (conn *ConnectionSet) AllConnections() bool
AllConnections returns true if all ports are allowed for all protocols
func (*ConnectionSet) ContainedIn ¶
func (conn *ConnectionSet) ContainedIn(other *ConnectionSet) bool
ContainedIn returns true if current ConnectionSet is conatained in the input ConnectionSet object
func (*ConnectionSet) Contains ¶
func (conn *ConnectionSet) Contains(port, protocol string) bool
Contains returns true if the input port+protocol is an allowed connection
func (*ConnectionSet) Equal ¶
func (conn *ConnectionSet) Equal(other *ConnectionSet) bool
Equal returns true if the current ConnectionSet object is equal to the input object
func (*ConnectionSet) Intersection ¶
func (conn *ConnectionSet) Intersection(other *ConnectionSet)
Intersection updates ConnectionSet object to be the intersection result with other ConnectionSet
func (*ConnectionSet) IsEmpty ¶
func (conn *ConnectionSet) IsEmpty() bool
IsEmpty returns true if the ConnectionSet has no allowed connections
func (*ConnectionSet) ProtocolsAndPortsMap ¶
func (conn *ConnectionSet) ProtocolsAndPortsMap() map[v1.Protocol][]PortRange
ProtocolsAndPortsMap() returns a map from allowed protocol to list of allowed ports ranges.
func (*ConnectionSet) String ¶
func (conn *ConnectionSet) String() string
String returns a string representation of the ConnectionSet object
func (*ConnectionSet) Union ¶
func (conn *ConnectionSet) Union(other *ConnectionSet)
Union updates ConnectionSet object to be the union result with other ConnectionSet
type IPBlock ¶ added in v0.4.0
type IPBlock struct {
// contains filtered or unexported fields
}
IPBlock captures a set of ip ranges
func DisjointIPBlocks ¶ added in v0.4.0
DisjointIPBlocks returns an IPBlock of disjoint ip ranges from 2 input IPBlock objects
func MergeIPBlocksList ¶ added in v0.4.0
func NewIPBlock ¶ added in v0.4.0
NewIPBlock returns an IPBlock object from input cidr str an exceptions cidr str
func NewIPBlockFromIPAddress ¶ added in v0.4.0
NewIPBlockFromIPAddress returns an IPBlock object from input ip address str
func (*IPBlock) ContainedIn ¶ added in v0.4.0
func (*IPBlock) IsIPAddress ¶ added in v0.4.0
IsIPAddress returns true if IPBlock object is a range of exactly one ip address from input
func (*IPBlock) Split ¶ added in v0.4.0
Split returns a set of IpBlock objects, each with a single range of ips
func (*IPBlock) ToIPRanges ¶ added in v0.4.0
ToIPRanges returns a string of the ip ranges in the current IPBlock object
type Interval ¶
Interval is an integer interval from Start to End
type PortRange ¶
type PortRange interface { // Start is the start port Start() int64 // End is the end port End() int64 // String returns a string representation of the PortRange object String() string }
PortRange describes a port or a range of ports for allowed traffic If start port equals end port, it represents a single port
type PortSet ¶
type PortSet struct { Ports CanonicalIntervalSet NamedPorts map[string]bool ExcludedNamedPorts map[string]bool }
PortSet: represents set of allowed ports in a connection
func MakePortSet ¶
MakePortSet: return a new PortSet object, with all ports or no ports allowed
func (*PortSet) AddPort ¶
func (p *PortSet) AddPort(port intstr.IntOrString)
AddPort: update current PortSet object with new added port as allowed
func (*PortSet) AddPortRange ¶
AddPortRange: update current PortSet object with new added port range as allowed
func (*PortSet) ContainedIn ¶
ContainedIn: return true if current PortSet object is contained in input PortSet object
func (*PortSet) Intersection ¶
Intersection: update current PortSet object as intersection with input PortSet object
func (*PortSet) RemovePort ¶
func (p *PortSet) RemovePort(port intstr.IntOrString)
RemovePort: update current PortSet object with removing input port from allowed ports