netconfig

package
v0.0.0-...-07f1eb8 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Overview

Package netconfig implements network configuration (interfaces, addresses, firewall rules, …).

Index

Constants

This section is empty.

Variables

View Source
var DefaultCounterObj = &nftables.CounterObj{}

DefaultCounterObj is overridden while testing

Functions

func Apply

func Apply(dir, root string) error

func LinkAddress

func LinkAddress(dir, ifname string) (net.IP, error)

LinkAddress returns the IP address configured for the interface ifname in interfaces.json.

Types

type BridgeDetails

type BridgeDetails struct {
	Name                   string   `json:"name"` // e.g. br0 or lan0
	InterfaceHardwareAddrs []string `json:"interface_hardware_addrs"`
}

type InterfaceConfig

type InterfaceConfig struct {
	Interfaces []InterfaceDetails `json:"interfaces"`
	Bridges    []BridgeDetails    `json:"bridges"`
}

type InterfaceDetails

type InterfaceDetails struct {
	HardwareAddr      string   `json:"hardware_addr"`       // e.g. dc:9b:9c:ee:72:fd
	SpoofHardwareAddr string   `json:"spoof_hardware_addr"` // e.g. dc:9b:9c:ee:72:fd
	Name              string   `json:"name"`                // e.g. uplink0, or lan0
	Addr              string   `json:"addr"`                // e.g. 192.168.42.1/24
	ExtraAddrs        []string `json:"extra_addrs"`         // e.g. ["192.168.23.1/24"]
	ExtraRoutes       []Route  `json:"extra_routes"`
	MTU               int      `json:"mtu"` // e.g. 1492 for PPPoE connections
	// FEC optionally allows configuring forward error correction, e.g. RS for
	// reed-solomon forward error correction, or Off to disable.
	//
	// Some network card and SFP module combinations (e.g. Mellanox ConnectX-4
	// with a Flexoptix P.B1625G.10.AD) need to explicitly be configured to use
	// RS forward error correction, otherwise they won’t link.
	FEC string `json:"fec"`
}

func Interface

func Interface(dir, ifname string) (InterfaceDetails, error)

Interface returns the InterfaceDetails configured for interface ifname in interfaces.json.

type Route

type Route struct {
	Destination string `json:"destination"` // e.g. 2a02:168:4a00:22::/64
	Gateway     string `json:"gateway"`     // e.g. fe80::1
}

Jump to

Keyboard shortcuts

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