node

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

func NewConnector

func NewConnector(name string, mode api.Mode) api.Connector

func NodeInit

func NodeInit()

Types

type DeviceNode

type DeviceNode struct {
	NodeMapName string

	DeviceConfig *config.DeviceConfig
	// contains filtered or unexported fields
}

修改 DeviceNode

func NewDeviceNode

func NewDeviceNode(id, name string, nodeType api.NodeType) *DeviceNode

func (*DeviceNode) AddPort

func (node *DeviceNode) AddPort(port api.Port, connection []*config.ConnectionInfo)

func (*DeviceNode) CmdIp

func (n *DeviceNode) CmdIp() string

func (*DeviceNode) ExtraInit

func (n *DeviceNode) ExtraInit(adapter api.Adapter, deviceConfig *config.DeviceConfig)

func (*DeviceNode) FlattenName

func (node *DeviceNode) FlattenName() string

func (*DeviceNode) FlattenPath

func (node *DeviceNode) FlattenPath() []string

func (*DeviceNode) GetDeviceConfig

func (n *DeviceNode) GetDeviceConfig() *config.DeviceConfig

func (*DeviceNode) GetOrCreateVrf

func (n *DeviceNode) GetOrCreateVrf(name string) api.Vrf

func (*DeviceNode) GetPortByID

func (n *DeviceNode) GetPortByID(id string) api.Port

func (*DeviceNode) GetPortByIfIndex

func (n *DeviceNode) GetPortByIfIndex(ifIndex int) api.Port

func (*DeviceNode) GetPortByNameOrAlias

func (n *DeviceNode) GetPortByNameOrAlias(name string) api.Port

func (*DeviceNode) GetVrf

func (n *DeviceNode) GetVrf(name string) api.Vrf

func (*DeviceNode) ID

func (n *DeviceNode) ID() string

func (*DeviceNode) IpRouteCheck

func (node *DeviceNode) IpRouteCheck(netList network.NetworkList, inPort, vrf string, af network.IPFamily) (bool, *tools.Table, []string, error)

IpRouteCheck 实现 api.Node 接口,保持向后兼容

func (*DeviceNode) IpRouteCheckInternal

func (node *DeviceNode) IpRouteCheckInternal(netList network.NetworkList, inPort, vrf string, af network.IPFamily) *model.RouteCheckResult

IpRouteCheckInternal 内部路由检查方法,返回 RouteCheckResult(公开方法供 traverse 包使用)

func (*DeviceNode) Ipv4RouteCheck

func (node *DeviceNode) Ipv4RouteCheck(netList network.NetworkList, inPort, vrf string) (bool, *tools.Table, []string, error)

func (*DeviceNode) Ipv4RouteTable

func (node *DeviceNode) Ipv4RouteTable(vrfName string) *network.AddressTable

func (*DeviceNode) Ipv6RouteCheck

func (node *DeviceNode) Ipv6RouteCheck(netList network.NetworkList, inPort, vrf string) (bool, *tools.Table, []string, error)

func (*DeviceNode) Ipv6RouteTable

func (node *DeviceNode) Ipv6RouteTable(vrfName string) *network.AddressTable

func (*DeviceNode) MarshalJSON

func (n *DeviceNode) MarshalJSON() ([]byte, error)

MarshalJSON 实现 JSON 序列化

func (*DeviceNode) Name

func (n *DeviceNode) Name() string

func (*DeviceNode) NodeType

func (n *DeviceNode) NodeType() api.NodeType

func (*DeviceNode) PortList

func (n *DeviceNode) PortList() []api.Port

func (*DeviceNode) PortRefs

func (n *DeviceNode) PortRefs() []string

func (*DeviceNode) SetDeviceConfig

func (n *DeviceNode) SetDeviceConfig(deviceConfig *config.DeviceConfig)

func (*DeviceNode) SetIpv4RouteTable

func (n *DeviceNode) SetIpv4RouteTable(vrfName string, table *network.AddressTable)

func (*DeviceNode) SetIpv6RouteTable

func (n *DeviceNode) SetIpv6RouteTable(vrfName string, table *network.AddressTable)

func (*DeviceNode) TypeName

func (n *DeviceNode) TypeName() string

func (*DeviceNode) UnmarshalJSON

func (n *DeviceNode) UnmarshalJSON(data []byte) error

UnmarshalJSON 实现 JSON 反序列化

func (*DeviceNode) Vrfs

func (n *DeviceNode) Vrfs() []api.Vrf

func (*DeviceNode) WithCmdIp

func (n *DeviceNode) WithCmdIp(ip string)

func (*DeviceNode) WithID

func (n *DeviceNode) WithID(id string) api.Node

func (*DeviceNode) WithName

func (n *DeviceNode) WithName(name string) api.Node

func (*DeviceNode) WithNodeMap

func (node *DeviceNode) WithNodeMap(name string) api.Node

func (*DeviceNode) WithNodeType

func (n *DeviceNode) WithNodeType(t api.NodeType)

func (*DeviceNode) WithPortIterator

func (n *DeviceNode) WithPortIterator(iterator api.PortIterator) api.Node

type FhrpGroup

type FhrpGroup struct {
	FhrpGroupIp string                   `json:"group_ip" gorm:"group_ip"`
	FhrpMode    api.FhrpMode             `json:"fhrp_mode" gorm:"fhrp_mode"`
	Members     []api.Member             `json:"members" gorm:"members"`
	Chain       *validator.ValidateChain `json:"-" gorm:"-"`
}

func NewFhrpGroup

func NewFhrpGroup(FhrpGroupIp string, mode api.FhrpMode) *FhrpGroup

func (*FhrpGroup) Active

func (g *FhrpGroup) Active() api.Member

func (*FhrpGroup) AddMember

func (g *FhrpGroup) AddMember(member api.Member)

func (*FhrpGroup) GroupIp

func (fg *FhrpGroup) GroupIp() string

func (FhrpGroup) MarshalJSON

func (fg FhrpGroup) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface

func (fg FhrpGroup) MarshalJSON() ([]byte, error) {
	type Alias FhrpGroup
	members := make([]json.RawMessage, len(fg.Members))
	for i, member := range fg.Members {
		b, err := member.MarshalJSON()
		if err != nil {
			return nil, err
		}
		members[i] = json.RawMessage(b)
	}
	return json.Marshal(&struct {
		Alias
		FhrpMode string            `json:"fhrp_mode"`
		Members  []json.RawMessage `json:"members"`
	}{
		Alias:    Alias(fg),
		FhrpMode: fg.FhrpMode.String(),
		Members:  members,
	})
}

func (FhrpGroup) TableName

func (FhrpGroup) TableName() string

func (*FhrpGroup) TypeName

func (fg *FhrpGroup) TypeName() string

func (*FhrpGroup) UnmarshalJSON

func (fg *FhrpGroup) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface

type FhrpGroupValidator

type FhrpGroupValidator struct{}

func (*FhrpGroupValidator) Validate

func (v *FhrpGroupValidator) Validate(data map[string]interface{}) validator.Result

type InterfaceConnectionValidator

type InterfaceConnectionValidator struct{}

func (InterfaceConnectionValidator) Validate

func (icv InterfaceConnectionValidator) Validate(data map[string]interface{}) validator.Result

type IpAddressConflictValidator

type IpAddressConflictValidator struct{}

func (*IpAddressConflictValidator) Validate

func (iv *IpAddressConflictValidator) Validate(data map[string]interface{}) validator.Result

type Member

type Member struct {
	MemberPortName string       `json:"port_name" gorm:"column:port_name"`
	FrhgGroupId    int          `json:"group_id" gorm:"column:group_id"`
	MemberIp       string       `json:"ip" gorm:"column:ip"`
	Priority       int          `json:"priority" gorm:"column:priority"`
	MemberFhrpMode api.FhrpMode `json:"mode" gorm:"column:fhrp_mode"`
	State          State        `json:"state" gorm:"column:state"`
}

func NewMember

func NewMember(MemberPortName, MemberIp, state, mode string, groupId, Priority int) *Member

func NewMember(MemberPortName, MemberIp, state, mode string, groupId, Priority int, port *Port) *Member {

func (Member) FhrpMode

func (m Member) FhrpMode() api.FhrpMode

func (Member) Hit

func (m Member) Hit(MemberIp string) bool

func (Member) Ip

func (m Member) Ip() string

func (Member) IsActive

func (m Member) IsActive() bool

func (Member) MarshalJSON

func (m Member) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface

func (Member) PortName

func (m Member) PortName() string

func (Member) TableName

func (Member) TableName() string

func (Member) TypeName

func (m Member) TypeName() string

func (*Member) UnmarshalJSON

func (m *Member) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface

type NameDuplicationValidator

type NameDuplicationValidator struct{}

func (*NameDuplicationValidator) Validate

func (nv *NameDuplicationValidator) Validate(data map[string]interface{}) validator.Result

type NetworkInRouteValidator

type NetworkInRouteValidator struct{}

func (*NetworkInRouteValidator) Validate

func (nv *NetworkInRouteValidator) Validate(data map[string]interface{}) validator.Result

type NetworkListRuleValidator

type NetworkListRuleValidator struct{}

func (*NetworkListRuleValidator) Validate

func (nv *NetworkListRuleValidator) Validate(data map[string]interface{}) validator.Result

type NetworkTypeValidator

type NetworkTypeValidator struct{}

func (*NetworkTypeValidator) Validate

func (nv *NetworkTypeValidator) Validate(data map[string]interface{}) validator.Result

type NodeConnector

type NodeConnector struct {
	Name string `json:"name"`

	IPv4 api.StringList `json:"ipv4"`
	IPv6 api.StringList `json:"ipv6"`

	PortRawData api.ByteList `json:"port_raw_data"`

	FhrpGroup []api.FhrpGroup `json:"fhrp_group"`
	// contains filtered or unexported fields
}

func (*NodeConnector) AddFhrpGroupMember

func (c *NodeConnector) AddFhrpGroupMember(member api.Member)

func (*NodeConnector) Attach

func (c *NodeConnector) Attach(port api.Port)

func (*NodeConnector) GetOrCreateFhrpGroup

func (c *NodeConnector) GetOrCreateFhrpGroup(groupIp string, mode api.FhrpMode) api.FhrpGroup

func (*NodeConnector) HitByIp

func (c *NodeConnector) HitByIp(ipWithPrefix, vrf string) bool

func (*NodeConnector) HitByNetwork

func (c *NodeConnector) HitByNetwork(net network.AbbrNet, vrf string) bool

func (*NodeConnector) ID

func (c *NodeConnector) ID() string

func (*NodeConnector) IPv4List

func (c *NodeConnector) IPv4List() api.StringList

func (*NodeConnector) IPv6List

func (c *NodeConnector) IPv6List() api.StringList

func (*NodeConnector) MarshalJSON

func (c *NodeConnector) MarshalJSON() ([]byte, error)

MarshalJSON 实现 JSON 序列化

func (*NodeConnector) Mode

func (c *NodeConnector) Mode() api.Mode

func (*NodeConnector) Port

func (c *NodeConnector) Port(name string) api.Port

func (*NodeConnector) PortCount

func (c *NodeConnector) PortCount() int

func (*NodeConnector) PortList

func (c *NodeConnector) PortList() []api.Port

func (*NodeConnector) SelectNodeByIp

func (c *NodeConnector) SelectNodeByIp(ip, vrf string) (api.Node, api.Port)

func (*NodeConnector) SelectPortListByNetwork

func (c *NodeConnector) SelectPortListByNetwork(net network.AbbrNet, vrf string) []api.Port

func (*NodeConnector) TypeName

func (c *NodeConnector) TypeName() string

func (*NodeConnector) UnmarshalJSON

func (c *NodeConnector) UnmarshalJSON(data []byte) error

UnmarshalJSON 实现 JSON 反序列化

func (*NodeConnector) Verify

func (c *NodeConnector) Verify(port api.Port) validator.Result

func (*NodeConnector) WithPortIterator

func (c *NodeConnector) WithPortIterator(iterator api.PortIterator)

type NodePort

type NodePort struct {
	PortName       string                        `json:"port_name"`
	Alias          api.StringList                `json:"alias"`
	IpList         map[network.IPFamily][]string `json:"ip_list"`
	IpListRaw      string                        `json:"ip_list_raw"`
	Tenant         string                        `json:"tenant"`
	FhrpMembers    []api.Member                  `json:"fhrp_members"`
	FhrpMembersRaw string                        `json:"fhrp_members_raw"`
	PortVrf        string                        `json:"port_vrf"`
	RemoteVrf      api.StringList                `json:"remote_vrf"`
	SnmpIfIndex    int                           `json:"snmp_if_index"`
	NodeID         int                           `json:"node_id"`
	ParentNode     api.Node                      `json:"-"`
	Connector      string                        `json:"connector"`
	ConnectorRaw   string                        `json:"connector_raw"`
	PrimaryIpv4    string                        `json:"primary_ipv4"`
	PrimaryIpv6    string                        `json:"primary_ipv6"`
	InputAcl       string                        `json:"input_acl"`
	OutputAcl      string                        `json:"output_acl"`
	SecurityLevel  string                        `json:"security_level"`
	ZoneName       string                        `json:"zone_name"`
	Description    string                        `json:"description"`
	Status         api.PortStatus                `json:"status"`
	AreaIPv4       string                        `json:"area_ipv4"`
	AreaIPv6       string                        `json:"area_ipv6"`
	StubAreaIPv4   bool                          `json:"stub_area_ipv4"`
	StubAreaIPv6   bool                          `json:"stub_area_ipv6"`
	// contains filtered or unexported fields
}

func NewPort

func NewPort(name, tenant string, ip_list map[network.IPFamily][]string, members []api.Member) *NodePort

func (*NodePort) AddIpv4

func (p *NodePort) AddIpv4(ip string)

func (*NodePort) AddIpv6

func (p *NodePort) AddIpv6(ip string)

func (*NodePort) AliasName

func (p *NodePort) AliasName() []string

func (*NodePort) Area

func (p *NodePort) Area(ipFamily network.IPFamily) string

Area 获取指定 IP 地址族的 area

func (*NodePort) ConnectorID

func (p *NodePort) ConnectorID() string

func (*NodePort) FlattenName

func (p *NodePort) FlattenName() string

func (*NodePort) FlattenPath

func (p *NodePort) FlattenPath() []string

func (*NodePort) FullMatchByIp

func (p *NodePort) FullMatchByIp(ip, PortVrf string) bool

func (*NodePort) GetIpList

func (p *NodePort) GetIpList() map[network.IPFamily][]string

func (*NodePort) HitByIfIndex

func (p *NodePort) HitByIfIndex(SnmpIfIndex int) bool

func (p *NodePort) HitByNetwork(net *network.IPNet) bool { for _, family := range []string{"ipv4", "ipv6"} { for _, _ip := range p.IpList[family] { interfaceIp, _ := network.ParseIPNet(_ip) if interfaceIp.MatchIPNet(net) { return true } } }

return false }

func (*NodePort) HitByIp

func (p *NodePort) HitByIp(target, PortVrf string) bool

func (*NodePort) HitByIpWithoutPrefix

func (p *NodePort) HitByIpWithoutPrefix(target, PortVrf string) bool

func (*NodePort) HitByName

func (p *NodePort) HitByName(name string) bool

func (*NodePort) HitByNetwork

func (p *NodePort) HitByNetwork(net network.AbbrNet) bool

func (*NodePort) ID

func (p *NodePort) ID() string

func (*NodePort) IfIndex

func (p *NodePort) IfIndex() int

func (*NodePort) Ipv4List

func (p *NodePort) Ipv4List() []string

func (*NodePort) Ipv6List

func (p *NodePort) Ipv6List() []string

func (*NodePort) IsStubArea

func (p *NodePort) IsStubArea(ipFamily network.IPFamily) bool

IsStubArea 获取指定 IP 地址族的 stub area 标记

func (NodePort) MarshalJSON

func (p NodePort) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface

func (*NodePort) MatchVrfOrPeerVrf

func (p *NodePort) MatchVrfOrPeerVrf(name string) bool

func (*NodePort) Members

func (p *NodePort) Members() []api.Member

func (*NodePort) Name

func (p *NodePort) Name() string

func (*NodePort) NetworkGroup

func (p *NodePort) NetworkGroup() *network.NetworkGroup

func (*NodePort) Node

func (p *NodePort) Node() api.Node

func (*NodePort) PeerVrf

func (p *NodePort) PeerVrf() []string

func (NodePort) TableName

func (NodePort) TableName() string

func (*NodePort) TypeName

func (p *NodePort) TypeName() string

func (*NodePort) UnmarshalJSON

func (p *NodePort) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface

func (*NodePort) V4NetworkGroup

func (p *NodePort) V4NetworkGroup() *network.NetworkGroup

func (*NodePort) V6NetworkGroup

func (p *NodePort) V6NetworkGroup() *network.NetworkGroup

func (*NodePort) Vrf

func (p *NodePort) Vrf() string

func (*NodePort) WithAliasName

func (p *NodePort) WithAliasName(name string) api.Port

func (*NodePort) WithArea

func (p *NodePort) WithArea(areaName string, ipFamily network.IPFamily) api.Port

WithArea 设置指定 IP 地址族的 area

func (*NodePort) WithConnectorID

func (p *NodePort) WithConnectorID(id string)

func (*NodePort) WithDescription

func (p *NodePort) WithDescription(description string) api.Port

func (*NodePort) WithID

func (p *NodePort) WithID(id string) api.Port

func (*NodePort) WithIfIndex

func (p *NodePort) WithIfIndex(SnmpIfIndex int) api.Port

func (*NodePort) WithNode

func (p *NodePort) WithNode(node api.Node) api.Port

func (*NodePort) WithPeerVrf

func (p *NodePort) WithPeerVrf(name string) api.Port

func (*NodePort) WithStatus

func (p *NodePort) WithStatus(status string) api.Port

func (*NodePort) WithStubArea

func (p *NodePort) WithStubArea(isStubArea bool, ipFamily network.IPFamily) api.Port

WithStubArea 设置指定 IP 地址族的 stub area 标记

func (*NodePort) WithVrf

func (p *NodePort) WithVrf(PortVrf string) api.Port

type NodePortIpList

type NodePortIpList struct {
	//global.GVA_MODEL `mapstructure:",squash"`
	Ip         string
	IpType     network.IPFamily
	NodePortID int
}

type NodeVrf

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

func (*NodeVrf) Ipv4Table

func (nv *NodeVrf) Ipv4Table() *network.AddressTable

func (*NodeVrf) Ipv6Table

func (nv *NodeVrf) Ipv6Table() *network.AddressTable

func (*NodeVrf) MarshalJSON

func (nv *NodeVrf) MarshalJSON() ([]byte, error)

MarshalJSON 实现 JSON 序列化

func (*NodeVrf) Name

func (nv *NodeVrf) Name() string

func (*NodeVrf) TypeName

func (nv *NodeVrf) TypeName() string

func (*NodeVrf) UnmarshalJSON

func (nv *NodeVrf) UnmarshalJSON(data []byte) error

UnmarshalJSON 实现 JSON 反序列化

func (NodeVrf) WappterUuid

func (NodeVrf) WappterUuid() string

type State

type State int
const (
	UNKNOWN_STATE State = iota
	ACTIVE
	STANDBY
)

func ToState

func ToState(state string) State

func (State) String

func (s State) String() string

type VrfExistValidator

type VrfExistValidator struct{}

func (*VrfExistValidator) Validate

func (v *VrfExistValidator) Validate(data map[string]interface{}) validator.Result

Jump to

Keyboard shortcuts

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