model

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ActionTypeService = "service"
	ActionTypeServe   = "serve"
	ActionTypeForward = "forward"
	ActionTypeSend    = "send"
)
View Source
const (
	SuspicionLevelInfo = iota
	SuspicionLevelWarning
	SuspicionLevelCritical
	SuspicionLevelFatal
)
View Source
const (
	EndpointTypePod          = "pod"
	EndpointTypeNode         = "node"
	EndpointTypeService      = "service"
	EndpointTypeLoadbalancer = "lb"
	EndpointTypeExternal     = "external"
)
View Source
const (
	NetNodeTypePod      = "pod"
	NetNodeTypeNode     = "node"
	NetNodeTypeExternal = "external"
	NetNodeTypeGeneric  = "generic"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action struct {
	Type    ActionType
	Input   *Link
	Outputs []*Link
}

func ActionForward

func ActionForward(input *Link, outputs []*Link) *Action

func ActionSend

func ActionSend(outputs []*Link) *Action

func ActionServe

func ActionServe(input *Link) *Action

func ActionService

func ActionService(input *Link, outputs []*Link) *Action

type ActionType

type ActionType string

type Endpoint

type Endpoint struct {
	IP   string       `json:"ip"`
	Type EndpointType `json:"type"`
	Port uint16       `json:"port"`
}

func (Endpoint) String

func (e Endpoint) String() string

type EndpointType

type EndpointType string

type Hop

type Hop struct {
	Type NetNodeType
	ID   string
}
type Link struct {
	Type                 LinkType
	Source               *NetNode
	Destination          *NetNode
	Packet               *Packet
	SourceAttribute      LinkAttribute
	DestinationAttribute LinkAttribute

	Level int // for print
}

func (Link) GetID

func (l Link) GetID() string

type LinkAttribute

type LinkAttribute interface {
	GetAttrs() map[string]string
}

type LinkType

type LinkType string
const (
	LinkExternal LinkType = "external"
	LinkInfra    LinkType = "infra"
	LinkVeth     LinkType = "veth"
	LinkIPVlan   LinkType = "ipvlan"
	LinkLocal    LinkType = "local"
)

type NetNode

type NetNode struct {
	Type       NetNodeType
	ID         string
	Actions    map[*Link]*Action
	Suspicions []Suspicion
	// contains filtered or unexported fields
}

func NewNetNode

func NewNetNode(id string, nodeType NetNodeType) *NetNode

func (*NetNode) ActionOf

func (n *NetNode) ActionOf(input *Link) *Action

func (*NetNode) AddSuspicion

func (n *NetNode) AddSuspicion(level SuspicionLevel, msg string)

func (*NetNode) DoAction

func (n *NetNode) DoAction(action *Action)

func (*NetNode) GetID

func (n *NetNode) GetID() string

func (*NetNode) GetSuspicions

func (n *NetNode) GetSuspicions() []Suspicion

func (*NetNode) GetType

func (n *NetNode) GetType() NetNodeType

func (*NetNode) MaxSuspicionLevel

func (n *NetNode) MaxSuspicionLevel() SuspicionLevel

type NetNodeAction

type NetNodeAction interface {
	Send(dst Endpoint, protocol Protocol) ([]Transmission, error)
	Receive(upstream *Link) ([]Transmission, error)
}

type NetNodeType

type NetNodeType string

type NullAttribute

type NullAttribute struct {
}

func (NullAttribute) GetAttrs

func (a NullAttribute) GetAttrs() map[string]string

type Packet

type Packet struct {
	Src      net.IP
	Sport    uint16
	Dst      net.IP
	Dport    uint16
	Protocol Protocol
	Encap    *Packet
	Mark     uint32
}

func (*Packet) DeepCopy

func (p *Packet) DeepCopy() *Packet

func (*Packet) String

func (p *Packet) String() string

type PacketPath

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

func NewPacketPath

func NewPacketPath(origin *NetNode) *PacketPath

func (*PacketPath) GetLinkLabel

func (p *PacketPath) GetLinkLabel(link *Link, action *Action) string

func (*PacketPath) GetOriginNode

func (p *PacketPath) GetOriginNode() *NetNode
func (p *PacketPath) Links() []*Link

func (*PacketPath) Nodes

func (p *PacketPath) Nodes() []*NetNode

func (*PacketPath) Paths

func (p *PacketPath) Paths() string

type Protocol

type Protocol string
const (
	TCP  Protocol = "tcp"
	UDP  Protocol = "udp"
	IPv4 Protocol = "ipv4"
)

type SimpleLinkAttribute

type SimpleLinkAttribute struct {
	Interface string
	IP        string
}

func (SimpleLinkAttribute) GetAttrs

func (a SimpleLinkAttribute) GetAttrs() map[string]string

type Suspicion

type Suspicion struct {
	Level   SuspicionLevel
	Message string
}

type SuspicionLevel

type SuspicionLevel int

func (SuspicionLevel) String

func (s SuspicionLevel) String() string

type Transmission

type Transmission struct {
	NextHop Hop
	Link    *Link
}

type VEthLinkAttribute

type VEthLinkAttribute struct {
	SimpleLinkAttribute
	PeerIndex int
}

func (VEthLinkAttribute) GetAttrs

func (v VEthLinkAttribute) GetAttrs() map[string]string

Jump to

Keyboard shortcuts

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