config

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AttachModeNative  = "native"
	AttachModeGeneric = "generic"
)
View Source
const (
	LoggingSystemOutputStdout = "stdout"
	LoggingSystemOutputFile   = "file"
)
View Source
const (
	UpfNodeID = "0.0.0.0"
)

Variables

View Source
var CheckInterfaceExistsFunc = func(name string) (bool, error) {
	networkInterface, err := net.InterfaceByName(name)
	if err != nil {
		return false, err
	}
	if networkInterface == nil {
		return false, nil
	}
	return true, nil
}
View Source
var GetInterfaceIPFunc = func(name string) (string, error) {
	iface, err := net.InterfaceByName(name)
	if err != nil {
		return "", err
	}

	addresses, err := iface.Addrs()
	if err != nil {
		return "", err
	}

	for _, addr := range addresses {
		if ip, _, err := net.ParseCIDR(addr.String()); err == nil {
			if ip.To4() != nil {
				return ip.String(), nil
			}
		}
	}

	return "", errors.New("no valid IPv4 address found")
}
View Source
var GetInterfaceNameFunc = func(address string) (string, error) {
	if address == "" {
		return "", errors.New("address is empty")
	}
	interfaces, err := net.Interfaces()
	if err != nil {
		return "", fmt.Errorf("cannot list network interfaces: %w", err)
	}

	for _, iface := range interfaces {
		addresses, err := iface.Addrs()
		if err != nil {
			return "", err
		}

		for _, addr := range addresses {
			if ip, _, err := net.ParseCIDR(addr.String()); err == nil {
				if ip.String() == address {
					return iface.Name, nil
				}
			}
		}
	}

	return "", nil
}
View Source
var GetVLANConfigForInterfaceFunc = func(name string) (*VlanConfig, error) {
	link, err := netlink.LinkByName(name)
	if err != nil {
		return nil, err
	}
	if link.Type() == "vlan" {
		vlanLink := link.(*netlink.Vlan)
		parentLink, err := netlink.LinkByIndex(vlanLink.ParentIndex)
		if err != nil {
			return nil, err
		}
		config := VlanConfig{MasterInterface: parentLink.Attrs().Name, VlanId: vlanLink.VlanId}

		return &config, nil
	}
	return nil, nil
}

Functions

func GetInterfaceIP added in v0.0.7

func GetInterfaceIP(name string) (string, error)

func GetInterfaceName added in v0.4.1

func GetInterfaceName(address string) (string, error)

func InterfaceExists added in v0.0.7

func InterfaceExists(name string) (bool, error)

Types

type APIInterface

type APIInterface struct {
	Address string
	Port    int
	TLS     TLS
}

type APIInterfaceYaml

type APIInterfaceYaml struct {
	Name    string  `yaml:"name"`
	Address string  `yaml:"address"`
	Port    int     `yaml:"port"`
	TLS     TLSYaml `yaml:"tls"`
}

type APIYaml

type APIYaml struct {
	Port int     `yaml:"port"`
	TLS  TLSYaml `yaml:"tls"`
}

type AuditLogging added in v0.0.8

type AuditLogging struct {
	Output string
	Path   string
}

type AuditLoggingYaml added in v0.0.8

type AuditLoggingYaml struct {
	Output string `yaml:"output"`
	Path   string `yaml:"path"`
}

type Config

type Config struct {
	Logging    Logging
	DB         DB
	Interfaces Interfaces
	XDP        XDP
	Telemetry  Telemetry
}

func Validate

func Validate(filePath string) (Config, error)

type ConfigYAML

type ConfigYAML struct {
	Logging    LoggingYaml    `yaml:"logging"`
	DB         DBYaml         `yaml:"db"`
	Interfaces InterfacesYaml `yaml:"interfaces"`
	XDP        XDPYaml        `yaml:"xdp"`
	Telemetry  TelemetryYaml  `yaml:"telemetry"`
}

type DB

type DB struct {
	Path string
}

type DBYaml

type DBYaml struct {
	Path string `yaml:"path"`
}

type Interfaces

type Interfaces struct {
	N2  N2Interface
	N3  N3Interface
	N6  N6Interface
	API APIInterface
}

type InterfacesYaml

type InterfacesYaml struct {
	N2  N2InterfaceYaml  `yaml:"n2"`
	N3  N3InterfaceYaml  `yaml:"n3"`
	N6  N6InterfaceYaml  `yaml:"n6"`
	API APIInterfaceYaml `yaml:"api"`
}

type Logging added in v0.0.8

type Logging struct {
	SystemLogging SystemLogging
	AuditLogging  AuditLogging
}

type LoggingYaml added in v0.0.8

type LoggingYaml struct {
	SystemLogging SystemLoggingYaml `yaml:"system"`
	AuditLogging  AuditLoggingYaml  `yaml:"audit"`
}

type N2Interface added in v0.0.5

type N2Interface struct {
	Address string
	Port    int
}

type N2InterfaceYaml added in v0.0.5

type N2InterfaceYaml struct {
	Name    string `yaml:"name"`
	Address string `yaml:"address"`
	Port    int    `yaml:"port"`
}

type N3Interface

type N3Interface struct {
	Name       string
	Address    string
	VlanConfig *VlanConfig
}

type N3InterfaceYaml

type N3InterfaceYaml struct {
	Name    string `yaml:"name"`
	Address string `yaml:"address"`
}

type N6Interface

type N6Interface struct {
	Name       string
	VlanConfig *VlanConfig
}

type N6InterfaceYaml

type N6InterfaceYaml struct {
	Name string `yaml:"name"`
}

type SystemLogging added in v0.0.8

type SystemLogging struct {
	Level  string
	Output string
	Path   string
}

type SystemLoggingYaml added in v0.0.8

type SystemLoggingYaml struct {
	Level  string `yaml:"level"`
	Output string `yaml:"output"`
	Path   string `yaml:"path"`
}

type TLS

type TLS struct {
	Cert string
	Key  string
}

type TLSYaml

type TLSYaml struct {
	Cert string `yaml:"cert"`
	Key  string `yaml:"key"`
}

type Telemetry added in v0.0.18

type Telemetry struct {
	Enabled      bool
	OTLPEndpoint string // e.g., "otel-collector.default.svc:4317"
}

type TelemetryYaml added in v0.0.18

type TelemetryYaml struct {
	Enabled      bool   `yaml:"enabled"`
	OTLPEndpoint string `yaml:"otlp-endpoint"`
}

type UPFYaml

type UPFYaml struct {
	Interfaces []string `yaml:"interfaces"`
}

type VlanConfig added in v0.4.2

type VlanConfig struct {
	MasterInterface string
	VlanId          int
}

type XDP added in v0.0.6

type XDP struct {
	AttachMode string
}

type XDPYaml added in v0.0.6

type XDPYaml struct {
	AttachMode string `yaml:"attach-mode"`
}

Jump to

Keyboard shortcuts

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