Speed up downloads by combining multiple network connections in parallel
TypeScript bandwidth-aggregationcross-platformdesktop-appdownloaderdownloadmanagerlinuxmacosmulticonnectionparallel-downloadswindows
feat: add Linux network settings support and fallback probe hosts for latency measurement
Anmol Kapil81791d9d1136
diff --git a/src/main/ipc/handlers.ts b/src/main/ipc/handlers.tsindex 35c3dcd..6f506c9 100644--- a/src/main/ipc/handlers.ts+++ b/src/main/ipc/handlers.ts@@ -19,10 +19,20 @@ import { listActiveInterfaces } from '../network/interfaces'import { loadNetworkPreferences, saveNetworkPreference } from '../network/preferences'import { saveThemeSource } from '../settings'-const NETWORK_SETTINGS_URL =- process.platform === 'win32'- ? 'ms-settings:network-status'- : 'x-apple.systempreferences:com.apple.preference.network'+async function openNetworkSettings(): Promise<void> {+ if (process.platform === 'win32') {+ await shell.openExternal('ms-settings:network-status')+ } else if (process.platform === 'darwin') {+ await shell.openExternal('x-apple.systempreferences:com.apple.preference.network')+ } else if (process.platform === 'linux') {+ try {+ const { exec } = await import('node:child_process')+ exec('gnome-control-center network || nm-connection-editor || true')+ } catch {+ // Best-effort+ }+ }+}/** Typed wrapper around ipcMain.handle — the channel name picks its args/result shape out of* IpcContract, so a handler here that doesn't match what plexoApi (preload) actually calls is a@@ -77,7 +87,7 @@ export function registerIpcHandlers(getWindow: () => BrowserWindow | null): Down})handle('openNetworkSettings', async () => {- await shell.openExternal(NETWORK_SETTINGS_URL)+ await openNetworkSettings()})handle('probeUrl', async (_event, url) => probeUrl(url))diff --git a/src/main/network/latency.ts b/src/main/network/latency.tsindex 570b11f..c6e0ab5 100644--- a/src/main/network/latency.ts+++ b/src/main/network/latency.ts@@ -1,16 +1,16 @@import { connect } from 'node:net'import type { NetworkInterfaceInfo } from '../../shared/types'-const PROBE_HOST = '1.1.1.1'+const PROBE_HOSTS = ['1.1.1.1', '8.8.8.8']const PROBE_PORT = 443const TIMEOUT_MS = 2000/** Rough per-interface latency: time to open a TCP connection to a reliable* host, sourced from that interface's local address. null means unreachable. */-function measureLatency(localAddress: string): Promise<number | null> {+function measureLatencyToHost(localAddress: string, host: string): Promise<number | null> {return new Promise((resolve) => {const start = Date.now()- const socket = connect({ host: PROBE_HOST, port: PROBE_PORT, localAddress, family: 4 })+ const socket = connect({ host, port: PROBE_PORT, localAddress, family: 4 })let settled = falseconst finish = (result: number | null): void => {@@ -27,6 +27,14 @@ function measureLatency(localAddress: string): Promise<number | null> {})}+async function measureLatency(localAddress: string): Promise<number | null> {+ for (const host of PROBE_HOSTS) {+ const latency = await measureLatencyToHost(localAddress, host)+ if (latency !== null) return latency+ }+ return null+}+export async function measureLatencies(interfaces: NetworkInterfaceInfo[]): Promise<Record<string, number | null>> {