diff --git a/packages/client-api/src/providers/network/create-network-provider.ts b/packages/client-api/src/providers/network/create-network-provider.ts
index cda77780..3d854538 100644
--- a/packages/client-api/src/providers/network/create-network-provider.ts
+++ b/packages/client-api/src/providers/network/create-network-provider.ts
@@ -4,11 +4,52 @@ import type { NetworkProviderConfig } from '~/user-config';
import { createProviderListener } from '../create-provider-listener';
export interface NetworkVariables {
- defaultInterface: NetworkInterface;
- defaultGateway: Gateway;
+ defaultInterface: NetworkInterface | null;
+ defaultGateway: NetworkGateway | null;
interfaces: NetworkInterface[];
}
+export interface NetworkInterface {
+ name: string;
+ friendlyName: string | null;
+ description: string | null;
+ type: InterfaceType;
+ ipv4Addresses: string[];
+ ipv6Addresses: string[];
+ macAddress: string | null;
+ transmitSeed: number | null;
+ receiveSpeed: number | null;
+ dnsServers: string[];
+ isDefault: boolean;
+}
+
+export interface NetworkGateway {
+ macAddress: string;
+ ipv4Addresses: string[];
+ ipv6Addresses: string[];
+ ssid: string | null;
+ signalStrength: number | null;
+}
+
+export enum InterfaceType {
+ UNKNOWN = 'unknown',
+ ETHERNET = 'ethernet',
+ TOKEN_RING = 'token_ring',
+ FDDI = 'fddi',
+ PPP = 'ppp',
+ LOOPBACK = 'loopback',
+ SLIP = 'slip',
+ ATM = 'atm',
+ GENERIC_MODEM = 'generic_modem',
+ ISDN = 'isdn',
+ WIFI = 'wifi',
+ DSL = 'dsl',
+ TUNNEL = 'tunnel',
+ HIGH_PERFORMANCE_SERIAL_BUS = 'high_performance_serial_bus',
+ MOBILE_BROADBAND = 'mobile_broadband',
+ BRIDGE = 'bridge',
+}
+
export async function createNetworkProvider(
config: NetworkProviderConfig,
owner: Owner,
@@ -30,82 +71,3 @@ export async function createNetworkProvider(
},
};
}
-
-export interface NetworkInterface {
- name: string;
- friendlName: string;
- description: string;
- interfaceType: InterfaceType;
- ipv4: Ipv4Net;
- ipv6: Ipv6Net;
- macAddress: MacAddress;
- transmitSeed: number;
- receiveSpeed: number;
- dnsServers: (Ipv4Addr | Ipv6Addr)[];
- default: boolean;
-}
-
-export interface Gateway {
- macAddress: MacAddress;
- ipv4: Ipv4Addr[];
- ipv6: Ipv6Addr[];
- ssid: string;
- signal_strength: number;
- connected: boolean;
-}
-
-enum InterfaceType {
- Unknown,
- Ethernet,
- TokenRing,
- Fddi,
- BasicIsdn,
- PrimaryIsdn,
- Ppp,
- Loopback,
- Ethernet3Megabit,
- Slip,
- Atm,
- GenericModem,
- FastEthernetT,
- Isdn,
- FastEthernetFx,
- Wireless80211,
- AsymmetricDsl,
- RateAdaptDsl,
- SymmetricDsl,
- VeryHighSpeedDsl,
- IPOverAtm,
- GigabitEthernet,
- Tunnel,
- MultiRateSymmetricDsl,
- HighPerformanceSerialBus,
- Wman,
- Wwanpp,
- Wwanpp2,
- Bridge,
-}
-
-interface Ipv4Net {
- addr: Ipv4Addr;
- netmask: Ipv4Addr;
- prefixLength: number;
-}
-
-interface Ipv6Net {
- addr: Ipv6Addr;
- netmask: Ipv6Addr;
- prefixLength: number;
-}
-
-interface Ipv6Addr {
- octects: number[];
-}
-
-interface Ipv4Addr {
- octects: number[];
-}
-
-interface MacAddress {
- octects: number[];
-}
diff --git a/packages/desktop/resources/sample-config.yaml b/packages/desktop/resources/sample-config.yaml
index a3b35b15..45b8bd43 100644
--- a/packages/desktop/resources/sample-config.yaml
+++ b/packages/desktop/resources/sample-config.yaml
@@ -108,18 +108,19 @@ window/bar:
template/network:
providers: ['network']
template: |
-
- @if (network.defaultInterface.type === 'Ethernet') {
- @if (network.defaultGateway.isConnected !== true) { }
- @else { }
+ @if (network.defaultInterface.type === 'ethernet') {
+
+ } @else if (network.defaultInterface.type === 'wifi') {
+ @if (network.defaultGateway?.signalStrength >= 80) { }
+ @else if (network.defaultGateway?.signalStrength >= 65) { }
+ @else if (network.defaultGateway?.signalStrength >= 40) { }
+ @else if (network.defaultGateway?.signalStrength >= 25) { }
+ @else { }
+ {{ network.defaultGateway?.ssid }}
+ } @else {
+
}
- @else if (network.defaultGateway.isConnected !== true) { }
- @else if (network.defaultGateway.signalStrengthPercent >= 80) { }
- @else if (network.defaultGateway.signalStrengthPercent >= 65) { }
- @else if (network.defaultGateway.signalStrengthPercent >= 40) { }
- @else if (network.defaultGateway.signalStrengthPercent >= 25) { }
- @else { }
template/memory:
providers: ['memory']
diff --git a/packages/desktop/src/providers/network/variables.rs b/packages/desktop/src/providers/network/variables.rs
index 921b92d2..f8070fe3 100644
--- a/packages/desktop/src/providers/network/variables.rs
+++ b/packages/desktop/src/providers/network/variables.rs
@@ -37,7 +37,7 @@ pub struct NetworkGateway {
}
#[derive(Serialize, Debug, Clone)]
-#[serde(rename_all = "camelCase")]
+#[serde(rename_all = "snake_case")]
pub enum InterfaceType {
Unknown,
Ethernet,