//go:build !windows package netcfg import ( "errors" "fmt" "gitea.apointless.space/bsncubed/ipswap/internal/preset" ) // ErrElevationRequired keeps the non-Windows build type-compatible so the rest // of the tree compiles and `go vet ./...` is useful during development on // Linux. Nothing here touches a real adapter. var ErrElevationRequired = errors.New("this operation requires an elevated process") // ErrUnsupported is returned by every write path off Windows. var ErrUnsupported = errors.New("adapter configuration is only supported on Windows") // Stub is a Manager that reports a plausible fixture instead of touching the // host. It exists so the tray, the editor server and the confirmation text can // be exercised on the development machine. type Stub struct{} // New returns the platform Manager. func New() Manager { return Stub{} } func (Stub) Adapters() ([]Adapter, error) { return []Adapter{ {Name: "Ethernet", Description: "Stub adapter (non-Windows build)", Up: true}, {Name: "Wi-Fi", Description: "Stub adapter (non-Windows build)", Up: false}, }, nil } func (Stub) Current(adapter string) (LiveConfig, error) { return LiveConfig{ Adapter: adapter, DHCP: true, Addresses: []preset.Address{{Address: "192.168.1.87", Prefix: 24}}, Gateways: []string{"192.168.1.1"}, DNS: []string{"192.168.1.1"}, DNSFromDHCP: true, }, nil } func (Stub) Apply(plan []Command) error { return fmt.Errorf("%w (plan had %d commands)", ErrUnsupported, len(plan)) }