network

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MergeConfiguredInterfaces added in v0.0.7

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

MergeConfiguredInterfaces overlays saved settings onto live interface data.

func NormalizeStaticRoute added in v0.0.7

func NormalizeStaticRoute(route model.StaticRoute) model.StaticRoute

func RouteKey added in v0.0.7

func RouteKey(route model.StaticRoute) string

func RoutesToRemove added in v0.0.7

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

Types

type BackendInfo added in v0.0.7

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

BackendInfo describes the active network persistence backend.

func GetBackendInfo added in v0.0.7

func GetBackendInfo() BackendInfo

GetBackendInfo returns metadata about the detected backend.

type BackendType added in v0.0.7

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 added in v0.0.7

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 added in v0.0.7

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 added in v0.0.7

type DarwinAdapter struct{}

DarwinAdapter implements NetworkAdapter for macOS.

func (*DarwinAdapter) ApplyInterfaceConfig added in v0.0.7

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

func (*DarwinAdapter) ApplyStaticRoute added in v0.0.7

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

func (*DarwinAdapter) BackendInfo added in v0.0.7

func (a *DarwinAdapter) BackendInfo() BackendInfo

func (*DarwinAdapter) GetInterfaces added in v0.0.7

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

func (*DarwinAdapter) GetRoutes added in v0.0.7

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

func (*DarwinAdapter) RemoveStaticRoute added in v0.0.7

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

func (*DarwinAdapter) ValidateConnectivity added in v0.0.7

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

type HostnameAccessStatus added in v0.0.7

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 added in v0.0.7

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

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

type HostnameDNSProxyStatus added in v0.0.7

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 added in v0.0.7

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 added in v0.0.7

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 added in v0.0.7

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 added in v0.0.7

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 added in v0.0.7

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 added in v0.0.7

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

ApplyStaticRoute applies a single static route immediately.

func (*NetworkManager) GetBackendInfo added in v0.0.7

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 added in v0.0.7

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

RemoveStaticRoute removes a single static route immediately.

func (*NetworkManager) ValidateConnectivity added in v0.0.7

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

ValidateConnectivity runs connectivity checks against the given targets.

type PersistBackend added in v0.0.7

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 added in v0.0.7

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 added in v0.0.7

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