sgroups

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// IPv4 IP family v4
	IPv4 = 4
	// IPv6 IP family v6
	IPv6 = 6
)

Variables

View Source
var (
	// ErrSPortsAreOverlapped -
	ErrSPortsAreOverlapped = errors.New("source ports have overlapped regions")

	// ErrUnexpectedNullPortRange -
	ErrUnexpectedNullPortRange = errors.New("unexpected null port range")

	// ErrInvalidFQDN -
	ErrInvalidFQDN = errors.New("invalid FQDN")
)
View Source
var PortRangeFactory = ranges.IntsFactory(PortNumber(0))

PortRangeFactory ...

View Source
var PortRangeFull = PortRangeFactory.Range(0, false, ^PortNumber(0), false)

PortRangeFull port range [0, 65535]

Functions

func AreRulePortsEq

func AreRulePortsEq(l, r []SGRulePorts) bool

AreRulePortsEq -

func ValidatePortRange

func ValidatePortRange(pr PortRange, canBeNull bool) error

ValidatePortRange portrange model validate

Types

type ChainDefaultAction

type ChainDefaultAction uint8

ChainDefaultAction default action for SG {DROP|ACCEPT}

const (
	// DEFAULT is mean default action
	DEFAULT ChainDefaultAction = iota

	// DROP drop action net packet
	DROP

	// ACCEPT accept action net packet
	ACCEPT
)

func (*ChainDefaultAction) FromString

func (a *ChainDefaultAction) FromString(s string) error

FromString inits from string

func (ChainDefaultAction) String

func (a ChainDefaultAction) String() string

String impl Stringer

func (ChainDefaultAction) Validate

func (a ChainDefaultAction) Validate() error

Validate ChainDefaultAction validator

type CidrSgRule

type CidrSgRule = ruleT[CidrSgRuleIdenity]

CidrSgRule proto:CIDR:SG:[INGRESS|EGRESS] rule

type CidrSgRuleIdenity

type CidrSgRuleIdenity struct {
	Transport NetworkTransport
	Traffic   Traffic
	SG        string
	CIDR      net.IPNet
}

CidrSgRuleIdenity -

func (CidrSgRuleIdenity) Cmp

Cmp -

func (CidrSgRuleIdenity) IdentityHash

func (o CidrSgRuleIdenity) IdentityHash() string

IdentityHash -

func (CidrSgRuleIdenity) IsEq

IsEq -

func (CidrSgRuleIdenity) String

func (o CidrSgRuleIdenity) String() string

String -

func (CidrSgRuleIdenity) Validate

func (o CidrSgRuleIdenity) Validate() error

Validate validate of CidrSgRuleIdenity

type FQDN

type FQDN string

FQDN -

func (FQDN) Cmp

func (o FQDN) Cmp(other FQDN) int

Cmp compare no case

func (FQDN) IsEq

func (o FQDN) IsEq(other FQDN) bool

IsEq chacke if is Eq with no case

func (FQDN) String

func (o FQDN) String() string

String impl Stringer

func (FQDN) Validate

func (o FQDN) Validate() error

Validate impl Validator

type FQDNRule

type FQDNRule struct {
	NdpiProtocols dict.RBSet[dict.StringCiKey]
	// contains filtered or unexported fields
}

FQDNRule rule for from SG to FQDN

func (FQDNRule) IsEq

func (rule FQDNRule) IsEq(other FQDNRule) bool

IsEq -

func (FQDNRule) Validate

func (o FQDNRule) Validate() error

Validate validate of FQDNRule

type FQDNRuleIdentity

type FQDNRuleIdentity struct {
	Transport NetworkTransport
	SgFrom    string
	FqdnTo    FQDN
}

FQDNRuleIdentity -

func (FQDNRuleIdentity) IdentityHash

func (sgRuleKey FQDNRuleIdentity) IdentityHash() string

IdentityHash makes ID as hash for FQDNRuleIdentity

func (FQDNRuleIdentity) IsEq

func (sgRuleKey FQDNRuleIdentity) IsEq(other FQDNRuleIdentity) bool

IsEq -

func (FQDNRuleIdentity) String

func (sgRuleKey FQDNRuleIdentity) String() string

String impl Stringer

func (FQDNRuleIdentity) Validate

func (o FQDNRuleIdentity) Validate() error

Validate validate of FQDNRuleIdentity

type ICMP

type ICMP struct {
	IPv   uint8             // Use in IP net version 4 or 6
	Types dict.RBSet[uint8] // Use ICMP message types set of [0-254]
}

ICMP an ICMP proto spec

func (ICMP) Validate

func (o ICMP) Validate() error

Validate impl Validator

type IESgSgIcmpRule added in v1.11.0

type IESgSgIcmpRule struct {
	Traffic Traffic
	SgLocal string
	Sg      string
	Icmp    ICMP
	Logs    bool
	Trace   bool
}

IESgSgIcmpRule <IN|E>GRESS:SG-SG:ICMP rule

func (IESgSgIcmpRule) ID added in v1.11.0

func (o IESgSgIcmpRule) ID() IESgSgIcmpRuleID

ID -

func (IESgSgIcmpRule) IsEq added in v1.11.0

func (r IESgSgIcmpRule) IsEq(other IESgSgIcmpRule) bool

IsEq -

func (IESgSgIcmpRule) Validate added in v1.11.0

func (o IESgSgIcmpRule) Validate() error

Validate impl Validator

type IESgSgIcmpRuleID added in v1.11.0

type IESgSgIcmpRuleID struct {
	Traffic Traffic
	IPv     uint8
	SgLocal string
	Sg      string
}

IESgSgIcmpRuleID <IN|E>GRESS:SG-SG:ICMP rule ID

func (IESgSgIcmpRuleID) IdentityHash added in v1.11.0

func (o IESgSgIcmpRuleID) IdentityHash() string

IdentityHash -

func (IESgSgIcmpRuleID) String added in v1.11.0

func (o IESgSgIcmpRuleID) String() string

String -

type Network

type Network struct {
	Net  net.IPNet
	Name NetworkName
}

Network is IP network

func (Network) IsEq

func (nw Network) IsEq(other Network) bool

IsEq -

func (Network) String

func (nw Network) String() string

String impl Stringer

func (Network) Validate

func (nw Network) Validate() error

Validate network model validate

type NetworkName

type NetworkName = string

NetworkName net nam

type NetworkTransport

type NetworkTransport uint8

NetworkTransport net transport

const (
	// TCP ...
	TCP NetworkTransport = iota

	// UDP ...
	UDP
)

func (*NetworkTransport) FromString

func (nt *NetworkTransport) FromString(s string) error

FromString init from string

func (NetworkTransport) String

func (nt NetworkTransport) String() string

String impl Stringer

func (NetworkTransport) Validate

func (nt NetworkTransport) Validate() error

Validate net transport validator

type PortNumber

type PortNumber = uint16

PortNumber net port num

type PortRange

type PortRange = ranges.Range[PortNumber]

PortRange net port range

type PortRanges

type PortRanges = ranges.MultiRange[PortNumber]

PortRanges net port ranges

func NewPortRarnges

func NewPortRarnges() PortRanges

NewPortRarnges is a port rarnges constructor

type PortSource

type PortSource string

func (*PortSource) FromPortRange

func (ps *PortSource) FromPortRange(r PortRange) error

FromPortRange inits from PortRange

func (*PortSource) FromPortRanges

func (ps *PortSource) FromPortRanges(rr PortRanges) error

FromPortRanges -

func (PortSource) IsEq

func (ps PortSource) IsEq(other PortSource) bool

IsEq -

func (PortSource) IsValid

func (ps PortSource) IsValid() bool

IsValid check string of port range is valid

func (PortSource) ToPortRange

func (ps PortSource) ToPortRange() (PortRange, error)

ToPortRange string to port range

func (PortSource) ToPortRanges

func (ps PortSource) ToPortRanges() (PortRanges, error)

ToPortRanges -

type SGRule

type SGRule = ruleT[SGRuleIdentity]

SGRule security rule for From-To security groups

type SGRuleIdentity

type SGRuleIdentity struct {
	Transport NetworkTransport
	SgFrom    string
	SgTo      string
}

SGRuleIdentity security rule ID as key

func (SGRuleIdentity) IdentityHash

func (sgRuleKey SGRuleIdentity) IdentityHash() string

IdentityHash makes ID as hash for SGRule

func (SGRuleIdentity) IsEq

func (sgRuleKey SGRuleIdentity) IsEq(other SGRuleIdentity) bool

IsEq -

func (SGRuleIdentity) String

func (sgRuleKey SGRuleIdentity) String() string

String impl Stringer

func (SGRuleIdentity) Validate

func (sgRuleKey SGRuleIdentity) Validate() error

Validate validate of SGRuleIdentity

type SGRulePorts

type SGRulePorts struct {
	S PortRanges
	D PortRanges
}

SGRulePorts source and destination port ranges

func (SGRulePorts) Validate

func (ports SGRulePorts) Validate() error

Validate SGRulePorts model validate

type SecurityGroup

type SecurityGroup struct {
	Name          string
	Networks      []NetworkName
	Logs          bool
	Trace         bool
	DefaultAction ChainDefaultAction
}

SecurityGroup security group for networks(s)

func (SecurityGroup) IsEq

func (sg SecurityGroup) IsEq(other SecurityGroup) bool

IsEq -

func (SecurityGroup) Validate

func (sg SecurityGroup) Validate() error

Validate security grpoup model validate

type SgIcmpRule

type SgIcmpRule struct {
	Sg    string
	Icmp  ICMP
	Logs  bool
	Trace bool
}

SgIcmpRule SG:ICMP default rule

func (SgIcmpRule) ID

func (o SgIcmpRule) ID() SgIcmpRuleID

ID -

func (SgIcmpRule) IsEq

func (o SgIcmpRule) IsEq(other SgIcmpRule) bool

IsEq -

func (SgIcmpRule) Validate

func (o SgIcmpRule) Validate() error

Validate impl Validator

type SgIcmpRuleID

type SgIcmpRuleID struct {
	IPv uint8
	Sg  string
}

SgIcmpRuleID SG:ICMP rule ID

func (SgIcmpRuleID) IdentityHash

func (o SgIcmpRuleID) IdentityHash() string

IdentityHash -

func (SgIcmpRuleID) String

func (o SgIcmpRuleID) String() string

String -

type SgSgIcmpRule

type SgSgIcmpRule struct {
	SgFrom string
	SgTo   string
	Icmp   ICMP
	Logs   bool
	Trace  bool
}

SgSgIcmpRule SG-SG:ICMP default rule

func (SgSgIcmpRule) ID

func (o SgSgIcmpRule) ID() SgSgIcmpRuleID

ID -

func (SgSgIcmpRule) IsEq

func (o SgSgIcmpRule) IsEq(other SgSgIcmpRule) bool

IsEq -

func (SgSgIcmpRule) Validate

func (o SgSgIcmpRule) Validate() error

Validate impl Validator

type SgSgIcmpRuleID

type SgSgIcmpRuleID struct {
	IPv    uint8
	SgFrom string
	SgTo   string
}

SgSgIcmpRuleID SG-SG:ICMP rule ID

func (SgSgIcmpRuleID) IdentityHash

func (o SgSgIcmpRuleID) IdentityHash() string

IdentityHash -

func (SgSgIcmpRuleID) String

func (o SgSgIcmpRuleID) String() string

String -

type SgSgRule added in v1.10.0

type SgSgRule = ruleT[SgSgRuleIdentity]

SgSgRule proto:SG:SG:[INGRESS|EGRESS] rule

type SgSgRuleIdentity added in v1.10.0

type SgSgRuleIdentity struct {
	Transport NetworkTransport
	Traffic   Traffic
	SgLocal   string
	Sg        string
}

SgSgRuleIdentity -

func (SgSgRuleIdentity) IdentityHash added in v1.10.0

func (o SgSgRuleIdentity) IdentityHash() string

IdentityHash implements ruleID.

func (SgSgRuleIdentity) IsEq added in v1.10.0

func (o SgSgRuleIdentity) IsEq(other SgSgRuleIdentity) bool

IsEq implements ruleID.

func (SgSgRuleIdentity) String added in v1.10.0

func (o SgSgRuleIdentity) String() string

String implements ruleID.

func (SgSgRuleIdentity) Validate added in v1.10.0

func (o SgSgRuleIdentity) Validate() error

Validate implements ruleID.

type SyncStatus

type SyncStatus struct {
	UpdatedAt time.Time
}

SyncStatus succeeded sync-op status

type Traffic

type Traffic uint8

Traffic packet traffic any of [INGRESS, EGRESS]

const (
	// INGRESS as is
	INGRESS Traffic = iota + 1

	// EGRESS as is
	EGRESS
)

func (*Traffic) FromString

func (tfc *Traffic) FromString(s string) error

FromString init from string

func (Traffic) String

func (tfc Traffic) String() string

String -

func (Traffic) Validate

func (tfc Traffic) Validate() error

Validate net transport validator

type Validatable

type Validatable = oz.Validatable

Validatable is a alias to oz.Validatable

Jump to

Keyboard shortcuts

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