api

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

type Adapter interface {
	ParseName(force bool) string
	PortList(force bool) []Port
	RouteTable(force bool) (ipv4TableMap, ipv6TableMap map[string]*network.AddressTable)
	GetConfig(force bool) interface{}
	BatchRun(interface{}) (interface{}, error)
	BatchConfig(p ...interface{}) (interface{}, error)
	TaskId() uint
	AttachChannel(out chan string) bool
	Info(bool) (*device.DeviceBaseInfo, error)
	GetRawConfig(string, bool) (any, error)
}

type AdapterType

type AdapterType int
const (
	LiveAdapter AdapterType = iota
	StringAdapter
)

type ByteList

type ByteList []byte

func (ByteList) GormDataType

func (ByteList) GormDataType() string

func (ByteList) MarshalJSON

func (m ByteList) MarshalJSON() (b []byte, err error)

func (*ByteList) Scan

func (m *ByteList) Scan(value interface{}) error

func (*ByteList) UnmarshalJSON

func (m *ByteList) UnmarshalJSON(b []byte) error

func (ByteList) Value

func (m ByteList) Value() (driver.Value, error)

type Connector

type Connector interface {
	TypedInterface
	JSONSerializer
	ID() string
	Verify(port Port) validator.Result
	GetOrCreateFhrpGroup(groupIp string, mode FhrpMode) FhrpGroup
	PortCount() int
	Port(name string) Port
	Attach(port Port)
	SelectPortListByNetwork(net network.AbbrNet, vrf string) []Port
	HitByNetwork(net network.AbbrNet, vrf string) bool
	HitByIp(ipWithPrefix, vrf string) bool
	SelectNodeByIp(ip, vrf string) (Node, Port)
	AddFhrpGroupMember(member Member)
	// NetworkList() []map[network.IPFamily][]string
	IPv4List() StringList
	IPv6List() StringList
	PortList() []Port
	Mode() Mode
	WithPortIterator(iterator PortIterator)
}

type ConnectorCatalog

type ConnectorCatalog int
const (
	NODE_CONNECTOR ConnectorCatalog
)

type FhrpGroup

type FhrpGroup interface {
	TypedInterface
	JSONSerializer
	AddMember(member Member)
	Active() Member
	GroupIp() string
}

type FhrpMode

type FhrpMode int
const (
	NONE FhrpMode = iota
	HSRP
	VRRP
)

func ToMode

func ToMode(mode string) FhrpMode

func (FhrpMode) String

func (m FhrpMode) String() string

type FirewallDumper

type FirewallDumper interface {
	ServiceObjectToDb(*gorm.DB, uint)
	NetworkObjectToDb(*gorm.DB, uint)
	PolicyToDb(*gorm.DB, uint)
	AclToDb(*gorm.DB, uint)
	AddressGroupToDb(*gorm.DB, uint)
	NatsToDb(*gorm.DB, uint)
	ExtraToDb(*gorm.DB, uint)
}

type JSONSerializer

type JSONSerializer interface {
	MarshalJSON() ([]byte, error)
	UnmarshalJSON([]byte) error
}

type Member

type Member interface {
	TypedInterface
	JSONSerializer
	IsActive() bool
	Hit(ip string) bool
	Ip() string
	FhrpMode() FhrpMode
	PortName() string
}

type Mode

type Mode int
const (
	P2P Mode = iota + 1
	MP
)

func (Mode) String

func (m Mode) String() string

type Node

type Node interface {
	TypedInterface
	JSONSerializer
	WithID(id string) Node
	ID() string
	GetOrCreateVrf(name string) Vrf
	GetVrf(name string) Vrf

	SetIpv4RouteTable(vrfName string, table *network.AddressTable)
	SetIpv6RouteTable(vrfName string, table *network.AddressTable)
	GetPortByNameOrAlias(name string) Port
	GetPortByIfIndex(ifIndex int) Port
	GetPortByID(id string) Port
	AddPort(port Port, connection []*config.ConnectionInfo)
	FlattenPath() []string
	FlattenName() string
	WithNodeMap(name string) Node
	WithName(name string) Node
	Ipv4RouteTable(vrfName string) *network.AddressTable
	Ipv6RouteTable(vrfName string) *network.AddressTable
	Ipv6RouteCheck(netList network.NetworkList, inPort, vrf string) (bool, *tools.Table, []string, error)
	Ipv4RouteCheck(netList network.NetworkList, inPort, vrf string) (bool, *tools.Table, []string, error)
	IpRouteCheck(netList network.NetworkList, inPort, vrf string, af network.IPFamily) (bool, *tools.Table, []string, error)
	Name() string
	Vrfs() []Vrf
	PortList() []Port
	PortRefs() []string
	WithCmdIp(ip string)
	CmdIp() string
	NodeType() NodeType
	WithPortIterator(iterator PortIterator) Node

	SetDeviceConfig(deviceConfig *config.DeviceConfig)
	GetDeviceConfig() *config.DeviceConfig

	ExtraInit(adapter Adapter, deviceConfig *config.DeviceConfig)
}

type NodeSession

type NodeSession interface {
	BatchRun(cmds interface{}, stopOnError bool) error
}

type NodeType

type NodeType int
const (
	ROUTER NodeType
	FIREWALL
	LB
)

func (NodeType) String

func (nt NodeType) String() string

type Port

type Port interface {
	TypedInterface
	JSONSerializer
	ID() string
	Name() string
	Node() Node
	// Connector() Connector
	ConnectorID() string
	// AttachToConnector(connector Connector)
	Members() []Member
	AliasName() []string
	PeerVrf() []string
	Vrf() string
	AddIpv6(ip string)
	AddIpv4(ip string)
	Ipv4List() []string
	Ipv6List() []string
	V4NetworkGroup() *network.NetworkGroup
	V6NetworkGroup() *network.NetworkGroup

	HitByNetwork(net network.AbbrNet) bool
	FullMatchByIp(ip, vrf string) bool
	HitByIpWithoutPrefix(target, vrf string) bool
	HitByIp(target, vrf string) bool
	HitByIfIndex(ifIndex int) bool
	MatchVrfOrPeerVrf(name string) bool
	HitByName(name string) bool
	IfIndex() int

	WithStatus(status string) Port
	WithNode(node Node) Port
	WithVrf(vrf string) Port
	WithPeerVrf(name string) Port
	WithAliasName(name string) Port
	GetIpList() map[network.IPFamily][]string
	FlattenName() string
	FlattenPath() []string
	NetworkGroup() *network.NetworkGroup
	WithID(id string) Port
	// WithConnector(c Connector)
	WithConnectorID(id string)
	// Area related methods
	WithArea(areaName string, ipFamily network.IPFamily) Port
	Area(ipFamily network.IPFamily) string
	// StubArea related methods
	WithStubArea(isStubArea bool, ipFamily network.IPFamily) Port
	IsStubArea(ipFamily network.IPFamily) bool
}

type PortIterator

type PortIterator interface {
	// GetPort 根据端口引用(名称或ID)返回对应的 Port 对象
	GetPort(ref string) Port
	// GetAllPorts 返回所有的 Port 对象
	GetAllPorts() []Port
}

PortIterator 定义了一个接口,用于从 NodeMap 中获取 Port 对象

type PortStatus

type PortStatus int
const (
	UNKNOWN PortStatus = iota
	DOWN
	UP
)

func NewPortStatusFromString

func NewPortStatusFromString(status string) PortStatus

func (PortStatus) String

func (p PortStatus) String() string

type StringList

type StringList []string

func (StringList) GormDataType

func (StringList) GormDataType() string

func (*StringList) Scan

func (m *StringList) Scan(value interface{}) error

func (StringList) Value

func (m StringList) Value() (driver.Value, error)

type TypedInterface

type TypedInterface interface {
	TypeName() string
}

type Vrf

type Vrf interface {
	TypedInterface
	JSONSerializer
	Name() string
	Ipv4Table() *network.AddressTable
	Ipv6Table() *network.AddressTable
}

Jump to

Keyboard shortcuts

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