route

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2025 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MinMetric max metric input
	MinMetric = 1
	// MaxMetric max metric input
	MaxMetric = 9999
	// MaxNetIDChar Max Network Identifier
	MaxNetIDChar = 40
)

Windows has some limitation regarding metric size that differ from Unix-like systems. Because of that we are limiting the min and max metric size based on Windows limits: see based on info from https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/route_ws2008

View Source
const (
	// InvalidNetworkString invalid network type string
	InvalidNetworkString = "Invalid"
	// IPv4NetworkString IPv4 network type string
	IPv4NetworkString = "IPv4"
	// IPv6NetworkString IPv6 network type string
	IPv6NetworkString = "IPv6"
	// DomainNetworkString domain network type string
	DomainNetworkString = "Domain"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type HAMap

type HAMap map[HAUniqueID][]*Route

HAMap is a map of HAUniqueID to a list of routes.

type HAUniqueID

type HAUniqueID string

HAUniqueID is a unique identifier that is used to group high availability routes.

func (HAUniqueID) NetID

func (id HAUniqueID) NetID() NetID

NetID returns the NetID from the HAUniqueID

func (HAUniqueID) String

func (id HAUniqueID) String() string

type ID

type ID string

ID is the unique route ID.

type NetID

type NetID string

NetID is the route network identifier, a human-readable string.

type NetworkType

type NetworkType int

NetworkType route network type

const (
	// InvalidNetwork invalid network type
	InvalidNetwork NetworkType = iota
	// IPv4Network IPv4 network type
	IPv4Network
	// IPv6Network IPv6 network type
	IPv6Network
	// DomainNetwork domain network type
	DomainNetwork
)

func ParseNetwork

func ParseNetwork(networkString string) (NetworkType, netip.Prefix, error)

ParseNetwork Parses a network prefix string and returns a netip.Prefix object and if is invalid, IPv4 or IPv6

func ToPrefixType

func ToPrefixType(prefix string) NetworkType

ToPrefixType returns a prefix type

func (NetworkType) String

func (p NetworkType) String() string

String returns prefix type string

type ResID

type ResID string

ResID is the resourceID part of a route.ID (first part before the colon).

type Route

type Route struct {
	ID ID `gorm:"primaryKey"`
	// AccountID is a reference to Account that this object belongs
	AccountID string `gorm:"index"`
	// Network and Domains are mutually exclusive
	Network             netip.Prefix `gorm:"serializer:json"`
	Domains             domain.List  `gorm:"serializer:json"`
	KeepRoute           bool
	NetID               NetID
	Description         string
	Peer                string
	PeerID              string   `gorm:"-"`
	PeerGroups          []string `gorm:"serializer:json"`
	NetworkType         NetworkType
	Masquerade          bool
	Metric              int
	Enabled             bool
	Groups              []string `gorm:"serializer:json"`
	AccessControlGroups []string `gorm:"serializer:json"`
	// SkipAutoApply indicates if this exit node route (0.0.0.0/0) should skip auto-application for client routing
	SkipAutoApply bool
}

Route represents a route

func (*Route) Copy

func (r *Route) Copy() *Route

Copy copies a route object

func (*Route) Equal

func (r *Route) Equal(other *Route) bool

Equal compares one route with the other

func (*Route) EventMeta

func (r *Route) EventMeta() map[string]any

EventMeta returns activity event meta related to the route

func (*Route) GetHAUniqueID

func (r *Route) GetHAUniqueID() HAUniqueID

GetHAUniqueID returns the HAUniqueID for the route, it can be used for grouping.

func (*Route) GetResourceID

func (r *Route) GetResourceID() ResID

GetResourceID returns the Networks ResID from the route ID. It's the part before the first colon in the ID string.

func (*Route) IsDynamic

func (r *Route) IsDynamic() bool

IsDynamic returns if the route is dynamic, i.e. has domains

func (*Route) NetString

func (r *Route) NetString() string

NetString returns the network string. If the route is dynamic, it returns the domains as comma-separated punycode-encoded string. If the route is not dynamic, it returns the network (prefix) string.

Jump to

Keyboard shortcuts

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