diff --git a/electron/main.ts b/electron/main.ts
index b560ea0f6..abe2a48d2 100644
--- a/electron/main.ts
+++ b/electron/main.ts
@@ -1,6 +1,8 @@
import { app, BrowserWindow, protocol, screen } from 'electron'
import { join } from 'path'
+import { setupNetworkService } from './services/network'
+
export const ROOT_PATH = {
dist: join(__dirname, '..'),
}
@@ -59,6 +61,8 @@ protocol.registerSchemesAsPrivileged([
},
])
+setupNetworkService()
+
app.whenReady().then(createWindow)
app.on('before-quit', () => {
diff --git a/electron/preload.ts b/electron/preload.ts
index e69de29bb..bfdd3fe8c 100644
--- a/electron/preload.ts
+++ b/electron/preload.ts
@@ -0,0 +1,5 @@
+import { contextBridge, ipcRenderer } from 'electron'
+
+contextBridge.exposeInMainWorld('electronAPI', {
+ getNetworkInfo: () => ipcRenderer.invoke('get-network-info'),
+})
diff --git a/electron/services/network.ts b/electron/services/network.ts
new file mode 100644
index 000000000..991b0f60f
--- /dev/null
+++ b/electron/services/network.ts
@@ -0,0 +1,39 @@
+import { ipcMain } from 'electron'
+import { networkInterfaces } from 'os'
+
+/**
+ * Information about the network
+ */
+interface NetworkInfo {
+ /**
+ * The subnet of the local machine
+ */
+ subnet: string
+}
+
+/**
+ * Get the network information
+ * @returns {NetworkInfo} The network information
+ */
+const getNetworkInfo = (): NetworkInfo => {
+ const nets = networkInterfaces()
+
+ for (const name of Object.keys(nets)) {
+ for (const net of nets[name] ?? []) {
+ // Skip over non-IPv4 and internal addresses
+ if (net.family === 'IPv4' && !net.internal) {
+ // Return the subnet (e.g., if IP is 192.168.1.5, return 192.168.1)
+ return { subnet: net.address.split('.').slice(0, 3).join('.') }
+ }
+ }
+ }
+
+ throw new Error('No network interface found.')
+}
+
+/**
+ * Setup the network service
+ */
+export const setupNetworkService = (): void => {
+ ipcMain.handle('get-network-info', getNetworkInfo)
+}
diff --git a/src/App.vue b/src/App.vue
index fc19580ca..94af043d2 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -315,15 +315,17 @@
+