Create wifi backend abstraction

This commit is contained in:
nemunaire 2026-01-01 22:13:18 +07:00
commit 79c28da9c5
7 changed files with 401 additions and 174 deletions

View file

@ -8,6 +8,7 @@ import (
func declareFlags(o *Config) {
flag.StringVar(&o.Bind, "bind", ":8081", "Bind port/socket")
flag.StringVar(&o.WifiInterface, "wifi-interface", "wlan0", "WiFi interface name")
flag.StringVar(&o.WifiBackend, "wifi-backend", "", "WiFi backend to use: 'iwd' or 'wpasupplicant' (required)")
flag.BoolVar(&o.UseARPDiscovery, "use-arp-discovery", true, "Use ARP table for device discovery instead of DHCP leases")
flag.StringVar(&o.DHCPLeasesPath, "dhcp-leases-path", "/var/lib/dhcp/dhcpd.leases", "Path to DHCP leases file")
flag.StringVar(&o.ARPTablePath, "arp-table-path", "/proc/net/arp", "Path to ARP table file")

View file

@ -11,6 +11,7 @@ import (
type Config struct {
Bind string
WifiInterface string
WifiBackend string
UseARPDiscovery bool
DHCPLeasesPath string
ARPTablePath string
@ -75,6 +76,11 @@ func ConsolidateConfig() (opts *Config, err error) {
return
}
// Validate configuration
if opts.WifiBackend != "iwd" && opts.WifiBackend != "wpasupplicant" {
log.Fatalf("wifi-backend must be set to 'iwd' or 'wpasupplicant' (got: '%s')", opts.WifiBackend)
}
return
}