network

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2026 License: GPL-2.0, GPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MergeConfiguredInterfaces

func MergeConfiguredInterfaces(live, configured []model.NetworkInterface) []model.NetworkInterface

MergeConfiguredInterfaces overlays saved settings onto live interface data.

func NormalizeStaticRoute

func NormalizeStaticRoute(route model.StaticRoute) model.StaticRoute

func RouteKey

func RouteKey(route model.StaticRoute) string

func RoutesToRemove

func RoutesToRemove(previous, current []model.StaticRoute) []model.StaticRoute

Types

type BackendInfo

type BackendInfo struct {
	Type  BackendType `json:"type"`
	Label string      `json:"label"`
}

BackendInfo describes the active network persistence backend.

func GetBackendInfo

func GetBackendInfo() BackendInfo

GetBackendInfo returns metadata about the detected backend.

type BackendType

type BackendType string

BackendType identifies the detected Linux network management tool.

const (
	BackendNetworkManager  BackendType = "networkmanager"
	BackendSystemdNetworkd BackendType = "systemd-networkd"
	BackendNetplan         BackendType = "netplan"
	BackendIfupdown        BackendType = "ifupdown"
	BackendIPRoute         BackendType = "iproute2"
)

func (BackendType) Label

func (t BackendType) Label() string

type DNSProxy

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

DNSProxy handles DNS requests for bare hostname access on port 53. Clients must use this device as their DNS server for bare hostnames to resolve.

func NewDNSProxy

func NewDNSProxy() *DNSProxy

NewDNSProxy creates a new DNSProxy.

func (*DNSProxy) ServeDNS

func (d *DNSProxy) ServeDNS(w dns.ResponseWriter, r *dns.Msg)

ServeDNS implements the dns.Handler interface.

func (*DNSProxy) Start

func (d *DNSProxy) Start(cfg model.HostnameConfig) error

Start starts the DNS proxy.

func (*DNSProxy) Status

func (d *DNSProxy) Status() HostnameDNSProxyStatus

Status returns the latest DNS proxy status.

func (*DNSProxy) Stop

func (d *DNSProxy) Stop()

Stop stops the DNS proxy.

type DarwinAdapter

type DarwinAdapter struct{}

DarwinAdapter implements NetworkAdapter for macOS.

func (*DarwinAdapter) ApplyInterfaceConfig

func (a *DarwinAdapter) ApplyInterfaceConfig(iface model.NetworkInterface) error

func (*DarwinAdapter) ApplyStaticRoute

func (a *DarwinAdapter) ApplyStaticRoute(route model.StaticRoute) error

func (*DarwinAdapter) BackendInfo

func (a *DarwinAdapter) BackendInfo() BackendInfo

func (*DarwinAdapter) GetInterfaces

func (a *DarwinAdapter) GetInterfaces() ([]model.NetworkInterface, error)

func (*DarwinAdapter) GetRoutes

func (a *DarwinAdapter) GetRoutes() ([]model.StaticRoute, error)

func (*DarwinAdapter) RemoveStaticRoute

func (a *DarwinAdapter) RemoveStaticRoute(route model.StaticRoute) error

func (*DarwinAdapter) ValidateConnectivity

func (a *DarwinAdapter) ValidateConnectivity(targets []model.ConnectivityTarget) (model.ConnectivityReport, error)

type HostnameAccessStatus

type HostnameAccessStatus struct {
	Name       string                 `json:"name"`
	HTTPPort   int                    `json:"http_port"`
	HTTPSPort  int                    `json:"https_port"`
	MDNS       HostnameMDNSStatus     `json:"mdns"`
	DNSProxy   HostnameDNSProxyStatus `json:"dns_proxy"`
	IPs        []string               `json:"ips"`
	DirectURLs []string               `json:"direct_urls"`
	MDNSURLs   []string               `json:"mdns_urls"`
}

HostnameAccessStatus summarizes how the gateway can be reached on the LAN.

func BuildHostnameAccessStatus

func BuildHostnameAccessStatus(cfg model.HostnameConfig, mdns HostnameMDNSStatus, dnsProxy HostnameDNSProxyStatus) HostnameAccessStatus

BuildHostnameAccessStatus composes access URLs and service status for the UI/API.

type HostnameDNSProxyStatus

type HostnameDNSProxyStatus struct {
	Enabled  bool     `json:"enabled"`
	Active   bool     `json:"active"`
	Hostname string   `json:"hostname"`
	IPs      []string `json:"ips,omitempty"`
	Error    string   `json:"error,omitempty"`
	Note     string   `json:"note,omitempty"`
}

HostnameDNSProxyStatus reports DNS proxy state for the UI/API.

type HostnameMDNSStatus

type HostnameMDNSStatus struct {
	Enabled  bool     `json:"enabled"`
	Active   bool     `json:"active"`
	Hostname string   `json:"hostname"`
	IPs      []string `json:"ips,omitempty"`
	Error    string   `json:"error,omitempty"`
}

HostnameMDNSStatus reports mDNS broadcast state for the UI/API.

type LinuxAdapter

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

func NewLinuxAdapter

func NewLinuxAdapter() *LinuxAdapter

func (*LinuxAdapter) ApplyInterfaceConfig

func (a *LinuxAdapter) ApplyInterfaceConfig(iface model.NetworkInterface) error

func (*LinuxAdapter) ApplyStaticRoute

func (a *LinuxAdapter) ApplyStaticRoute(route model.StaticRoute) error

func (*LinuxAdapter) BackendInfo

func (a *LinuxAdapter) BackendInfo() BackendInfo

func (*LinuxAdapter) GetInterfaces

func (a *LinuxAdapter) GetInterfaces() ([]model.NetworkInterface, error)

func (*LinuxAdapter) GetRoutes

func (a *LinuxAdapter) GetRoutes() ([]model.StaticRoute, error)

func (*LinuxAdapter) RemoveStaticRoute

func (a *LinuxAdapter) RemoveStaticRoute(route model.StaticRoute) error

func (*LinuxAdapter) ValidateConnectivity

func (a *LinuxAdapter) ValidateConnectivity(targets []model.ConnectivityTarget) (model.ConnectivityReport, error)

type MDNSServer

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

MDNSServer manages mDNS services.

func NewMDNSServer

func NewMDNSServer() *MDNSServer

NewMDNSServer creates a new MDNSServer.

func (*MDNSServer) Start

func (s *MDNSServer) Start(cfg model.HostnameConfig) error

Start starts the mDNS services based on configuration.

func (*MDNSServer) Status

func (s *MDNSServer) Status() HostnameMDNSStatus

Status returns the latest mDNS broadcast status.

func (*MDNSServer) Stop

func (s *MDNSServer) Stop()

Stop stops all mDNS services.

type NetworkAdapter

type NetworkAdapter interface {
	ApplyInterfaceConfig(iface model.NetworkInterface) error
	ApplyStaticRoute(route model.StaticRoute) error
	RemoveStaticRoute(route model.StaticRoute) error
	GetInterfaces() ([]model.NetworkInterface, error)
	GetRoutes() ([]model.StaticRoute, error)
	ValidateConnectivity(targets []model.ConnectivityTarget) (model.ConnectivityReport, error)
}

NetworkAdapter defines the interface for OS-specific network operations

func NewNetworkAdapter

func NewNetworkAdapter() NetworkAdapter

NewNetworkAdapter creates a platform-specific network adapter

type NetworkManager

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

NetworkManager manages network configurations and operations

func NewNetworkManager

func NewNetworkManager() *NetworkManager

NewNetworkManager creates a new NetworkManager

func (*NetworkManager) ApplyConfig

func (nm *NetworkManager) ApplyConfig(interfaces []model.NetworkInterface, routes []model.StaticRoute) error

ApplyConfig applies the given network configuration

func (*NetworkManager) ApplyConfigWithRouteSync

func (nm *NetworkManager) ApplyConfigWithRouteSync(interfaces []model.NetworkInterface, routes, previousRoutes []model.StaticRoute, validationTargets []model.ConnectivityTarget) error

ApplyConfigWithRouteSync applies network config and removes routes dropped from the previous config.

func (*NetworkManager) ApplyConfigWithTransaction

func (nm *NetworkManager) ApplyConfigWithTransaction(interfaces []model.NetworkInterface, routes []model.StaticRoute, validationTargets []model.ConnectivityTarget) error

ApplyConfigWithTransaction applies the given network configuration with transaction support (rollback on failure)

func (*NetworkManager) ApplyStaticRoute

func (nm *NetworkManager) ApplyStaticRoute(route model.StaticRoute) error

ApplyStaticRoute applies a single static route immediately.

func (*NetworkManager) GetBackendInfo

func (nm *NetworkManager) GetBackendInfo() BackendInfo

GetBackendInfo returns the detected OS network backend.

func (*NetworkManager) GetInterfaces

func (nm *NetworkManager) GetInterfaces() ([]model.NetworkInterface, error)

GetInterfaces returns the current status of all interfaces

func (*NetworkManager) GetRoutes

func (nm *NetworkManager) GetRoutes() ([]model.StaticRoute, error)

GetRoutes returns the current static routes

func (*NetworkManager) RemoveStaticRoute

func (nm *NetworkManager) RemoveStaticRoute(route model.StaticRoute) error

RemoveStaticRoute removes a single static route immediately.

func (*NetworkManager) ValidateConnectivity

func (nm *NetworkManager) ValidateConnectivity(targets []model.ConnectivityTarget) (model.ConnectivityReport, error)

ValidateConnectivity runs connectivity checks against the given targets.

type PersistBackend

type PersistBackend interface {
	Type() BackendType
	ApplyInterfaceConfig(iface model.NetworkInterface) error
	ApplyStaticRoute(route model.StaticRoute) error
}

PersistBackend persists network configuration through OS-specific tools.

func DetectPersistBackend

func DetectPersistBackend() PersistBackend

DetectPersistBackend selects the best available persistence backend.

type WindowsAdapter

type WindowsAdapter struct{}

WindowsAdapter implements NetworkAdapter for Windows

func (*WindowsAdapter) ApplyInterfaceConfig

func (a *WindowsAdapter) ApplyInterfaceConfig(iface model.NetworkInterface) error

func (*WindowsAdapter) ApplyStaticRoute

func (a *WindowsAdapter) ApplyStaticRoute(route model.StaticRoute) error

func (*WindowsAdapter) GetInterfaces

func (a *WindowsAdapter) GetInterfaces() ([]model.NetworkInterface, error)

func (*WindowsAdapter) GetRoutes

func (a *WindowsAdapter) GetRoutes() ([]model.StaticRoute, error)

func (*WindowsAdapter) RemoveStaticRoute

func (a *WindowsAdapter) RemoveStaticRoute(route model.StaticRoute) error

func (*WindowsAdapter) ValidateConnectivity

func (a *WindowsAdapter) ValidateConnectivity(targets []model.ConnectivityTarget) (model.ConnectivityReport, error)

Jump to

Keyboard shortcuts

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