Skip to content
395 changes: 395 additions & 0 deletions core/internal/mocks/network/mock_Backend.go

Large diffs are not rendered by default.

94 changes: 56 additions & 38 deletions core/internal/server/network/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ type Backend interface {
GetWiFiEnabled() (bool, error)
SetWiFiEnabled(enabled bool) error

GetCellularEnabled() (bool, error)
SetCellularEnabled(enabled bool) error

ScanWiFi() error
ScanWiFiDevice(device string) error
GetWiFiNetworkDetails(ssid string) (*NetworkInfoResponse, error)
Expand All @@ -27,6 +30,13 @@ type Backend interface {
DisconnectEthernetDevice(device string) error
ActivateWiredConnection(uuid string) error

GetCellularDevices() []CellularDevice
GetCellularConnections() ([]WiredConnection, error)
ConnectCellular() error
DisconnectCellular() error
DisconnectCellularDevice(device string) error
ActivateCellularConnection(uuid string) error

ListVPNProfiles() ([]VPNProfile, error)
ListActiveVPN() ([]VPNActive, error)
ConnectVPN(uuidOrName string, singleActive bool) error
Expand Down Expand Up @@ -59,42 +69,50 @@ type HotspotBackend interface {
}

type BackendState struct {
Backend string
NetworkStatus NetworkStatus
EthernetIP string
EthernetDevice string
EthernetConnected bool
EthernetConnectionUuid string
EthernetDevices []EthernetDevice
WiFiIP string
WiFiDevice string
WiFiConnected bool
WiFiEnabled bool
WiFiSSID string
WiFiBSSID string
WiFiSignal uint8
WiFiNetworks []WiFiNetwork
SavedWiFiNetworks []WiFiNetwork
WiFiDevices []WiFiDevice
HotspotAvailable bool
HotspotConfigured bool
HotspotEnabled bool
HotspotActivating bool
HotspotSecured bool
HotspotSSID string
HotspotDevice string
HotspotBand string
HotspotLastError string
WiredConnections []WiredConnection
VPNProfiles []VPNProfile
VPNActive []VPNActive
IsConnecting bool
ConnectingSSID string
ConnectingDevice string
ConnectingPreExisting bool
IsConnectingVPN bool
ConnectingVPNUUID string
LastError string
VPNError string
VPNErrorUuid string
Backend string
NetworkStatus NetworkStatus
EthernetIP string
EthernetDevice string
EthernetConnected bool
EthernetConnectionUuid string
EthernetDevices []EthernetDevice
CellularIP string
CellularDevice string
CellularConnected bool
CellularEnabled bool
CellularHardwareEnabled bool
CellularConnectionUuid string
CellularDevices []CellularDevice
CellularConnections []WiredConnection
WiFiIP string
WiFiDevice string
WiFiConnected bool
WiFiEnabled bool
WiFiSSID string
WiFiBSSID string
WiFiSignal uint8
WiFiNetworks []WiFiNetwork
SavedWiFiNetworks []WiFiNetwork
WiFiDevices []WiFiDevice
HotspotAvailable bool
HotspotConfigured bool
HotspotEnabled bool
HotspotActivating bool
HotspotSecured bool
HotspotSSID string
HotspotDevice string
HotspotBand string
HotspotLastError string
WiredConnections []WiredConnection
VPNProfiles []VPNProfile
VPNActive []VPNActive
IsConnecting bool
ConnectingSSID string
ConnectingDevice string
ConnectingPreExisting bool
IsConnectingVPN bool
ConnectingVPNUUID string
LastError string
VPNError string
VPNErrorUuid string
}
32 changes: 32 additions & 0 deletions core/internal/server/network/backend_hybrid_iwd_networkd.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,38 @@ func (b *HybridIwdNetworkdBackend) ActivateWiredConnection(uuid string) error {
return b.l3.ActivateWiredConnection(uuid)
}

func (b *HybridIwdNetworkdBackend) GetCellularDevices() []CellularDevice {
return []CellularDevice{}
}

func (b *HybridIwdNetworkdBackend) GetCellularEnabled() (bool, error) {
return false, fmt.Errorf("cellular radio control not supported in hybrid mode")
}

func (b *HybridIwdNetworkdBackend) SetCellularEnabled(enabled bool) error {
return fmt.Errorf("cellular radio control not supported in hybrid mode")
}

func (b *HybridIwdNetworkdBackend) GetCellularConnections() ([]WiredConnection, error) {
return nil, fmt.Errorf("cellular connections not supported in hybrid mode")
}

func (b *HybridIwdNetworkdBackend) ConnectCellular() error {
return fmt.Errorf("cellular connections not supported in hybrid mode")
}

func (b *HybridIwdNetworkdBackend) DisconnectCellular() error {
return fmt.Errorf("cellular connections not supported in hybrid mode")
}

func (b *HybridIwdNetworkdBackend) DisconnectCellularDevice(device string) error {
return fmt.Errorf("cellular connections not supported in hybrid mode")
}

func (b *HybridIwdNetworkdBackend) ActivateCellularConnection(uuid string) error {
return fmt.Errorf("cellular connections not supported in hybrid mode")
}

func (b *HybridIwdNetworkdBackend) ListVPNProfiles() ([]VPNProfile, error) {
return []VPNProfile{}, nil
}
Expand Down
32 changes: 32 additions & 0 deletions core/internal/server/network/backend_iwd_unimplemented.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,38 @@ func (b *IWDBackend) ActivateWiredConnection(uuid string) error {
return fmt.Errorf("wired connections not supported by iwd")
}

func (b *IWDBackend) GetCellularDevices() []CellularDevice {
return []CellularDevice{}
}

func (b *IWDBackend) GetCellularEnabled() (bool, error) {
return false, fmt.Errorf("cellular radio control not supported by iwd")
}

func (b *IWDBackend) SetCellularEnabled(enabled bool) error {
return fmt.Errorf("cellular radio control not supported by iwd")
}

func (b *IWDBackend) GetCellularConnections() ([]WiredConnection, error) {
return nil, fmt.Errorf("cellular connections not supported by iwd")
}

func (b *IWDBackend) ConnectCellular() error {
return fmt.Errorf("cellular connections not supported by iwd")
}

func (b *IWDBackend) DisconnectCellular() error {
return fmt.Errorf("cellular connections not supported by iwd")
}

func (b *IWDBackend) DisconnectCellularDevice(device string) error {
return fmt.Errorf("cellular connections not supported by iwd")
}

func (b *IWDBackend) ActivateCellularConnection(uuid string) error {
return fmt.Errorf("cellular connections not supported by iwd")
}

func (b *IWDBackend) ListVPNProfiles() ([]VPNProfile, error) {
return nil, fmt.Errorf("VPN not supported by iwd backend")
}
Expand Down
32 changes: 32 additions & 0 deletions core/internal/server/network/backend_networkd_unimplemented.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,35 @@ func (b *SystemdNetworkdBackend) DisconnectWiFiDevice(device string) error {
func (b *SystemdNetworkdBackend) GetWiFiDevices() []WiFiDevice {
return nil
}

func (b *SystemdNetworkdBackend) GetCellularDevices() []CellularDevice {
return []CellularDevice{}
}

func (b *SystemdNetworkdBackend) GetCellularEnabled() (bool, error) {
return false, fmt.Errorf("cellular radio control not supported by networkd backend")
}

func (b *SystemdNetworkdBackend) SetCellularEnabled(enabled bool) error {
return fmt.Errorf("cellular radio control not supported by networkd backend")
}

func (b *SystemdNetworkdBackend) GetCellularConnections() ([]WiredConnection, error) {
return nil, fmt.Errorf("cellular connections not supported by networkd backend")
}

func (b *SystemdNetworkdBackend) ConnectCellular() error {
return fmt.Errorf("cellular connections not supported by networkd backend")
}

func (b *SystemdNetworkdBackend) DisconnectCellular() error {
return fmt.Errorf("cellular connections not supported by networkd backend")
}

func (b *SystemdNetworkdBackend) DisconnectCellularDevice(device string) error {
return fmt.Errorf("cellular connections not supported by networkd backend")
}

func (b *SystemdNetworkdBackend) ActivateCellularConnection(uuid string) error {
return fmt.Errorf("cellular connections not supported by networkd backend")
}
Loading
Loading