sgroups

package
v1.14.0 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2024 License: MIT Imports: 18 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 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) IsEq added in v1.13.0

func (o ICMP) IsEq(other ICMP) bool

IsEq -

func (ICMP) Validate

func (o ICMP) Validate() error

Validate impl Validator

type IECidrSgIcmpRule added in v1.13.0

type IECidrSgIcmpRule struct {
	Traffic  Traffic
	CIDR     net.IPNet
	SG       string
	Icmp     ICMP
	Logs     bool
	Trace    bool
	Action   RuleAction
	Priority RulePriority
}

IECidrSgIcmpRule <IN|E>GRESS:CIDR-SG:ICMP rule

func (IECidrSgIcmpRule) ID added in v1.13.0

func (o IECidrSgIcmpRule) ID() IECidrSgIcmpRuleID

ID -

func (IECidrSgIcmpRule) IsEq added in v1.13.0

func (o IECidrSgIcmpRule) IsEq(other IECidrSgIcmpRule) bool

IsEq -

func (IECidrSgIcmpRule) Validate added in v1.13.0

func (o IECidrSgIcmpRule) Validate() error

type IECidrSgIcmpRuleID added in v1.13.0

type IECidrSgIcmpRuleID struct {
	Traffic Traffic
	IPv     uint8
	SG      string
	CIDR    net.IPNet
}

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

func (IECidrSgIcmpRuleID) Cmp added in v1.13.0

func (o IECidrSgIcmpRuleID) Cmp(other IECidrSgIcmpRuleID) int

Cmp -

func (IECidrSgIcmpRuleID) IdentityHash added in v1.13.0

func (o IECidrSgIcmpRuleID) IdentityHash() string

IdentityHash -

func (IECidrSgIcmpRuleID) String added in v1.13.0

func (o IECidrSgIcmpRuleID) String() string

String -

type IECidrSgRule added in v1.13.0

type IECidrSgRule = ruleT[IECidrSgRuleIdenity]

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

type IECidrSgRuleIdenity added in v1.13.0

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

IECidrSgRuleIdenity -

func (IECidrSgRuleIdenity) Cmp added in v1.13.0

Cmp -

func (IECidrSgRuleIdenity) IdentityHash added in v1.13.0

func (o IECidrSgRuleIdenity) IdentityHash() string

IdentityHash -

func (IECidrSgRuleIdenity) IsEq added in v1.13.0

IsEq -

func (IECidrSgRuleIdenity) String added in v1.13.0

func (o IECidrSgRuleIdenity) String() string

String -

func (IECidrSgRuleIdenity) Validate added in v1.13.0

func (o IECidrSgRuleIdenity) Validate() error

Validate validate of CidrSgRuleIdenity

type IESgSgIcmpRule added in v1.11.0

type IESgSgIcmpRule struct {
	Traffic  Traffic
	SgLocal  string
	Sg       string
	Icmp     ICMP
	Logs     bool
	Trace    bool
	Action   RuleAction
	Priority RulePriority
}

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 (o 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 IESgSgRule added in v1.13.0

type IESgSgRule = ruleT[IESgSgRuleIdentity]

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

type IESgSgRuleIdentity added in v1.13.0

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

IESgSgRuleIdentity -

func (IESgSgRuleIdentity) IdentityHash added in v1.13.0

func (o IESgSgRuleIdentity) IdentityHash() string

IdentityHash implements ruleID.

func (IESgSgRuleIdentity) IsEq added in v1.13.0

IsEq implements ruleID.

func (IESgSgRuleIdentity) String added in v1.13.0

func (o IESgSgRuleIdentity) String() string

String implements ruleID.

func (IESgSgRuleIdentity) Validate added in v1.13.0

func (o IESgSgRuleIdentity) Validate() error

Validate implements ruleID.

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 RuleAction added in v1.14.0

type RuleAction uint8

RuleAction terminal verdict action for rules

const (
	// RA_UNDEF -
	RA_UNDEF RuleAction = iota

	// RA_DROP setups rule to drop packet
	RA_DROP

	// RA_ACCEPT setups rule to accept packet
	RA_ACCEPT
)

func (*RuleAction) FromString added in v1.14.0

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

FromString init from string

func (RuleAction) String added in v1.14.0

func (a RuleAction) String() string

String impl Stringer

func (RuleAction) Validate added in v1.14.0

func (a RuleAction) Validate() error

Validate RuleAction validator

type RulePriority added in v1.14.0

type RulePriority struct {
	option.ValueOf[int16]
}

RulePriority represents rule priority i e relative placement pos in the rule list

func (RulePriority) IsEq added in v1.14.0

func (o RulePriority) IsEq(other RulePriority) bool

IsEq -

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
	Action RuleAction
}

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
	Action   RuleAction
	Priority RulePriority
}

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 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