Skip to content

armgit / plexo

Public Imported from GitHub
0

Speed up downloads by combining multiple network connections in parallel

fix: detect same-subnet conflicts and clarify single-stream mode on Windows (#20)

yparshant61032f5e096c056
diff --git a/README.md b/README.md
index eed8ea8..13129e5 100644
--- a/README.md
+++ b/README.md
@@ -18,6 +18,17 @@ https://github.com/user-attachments/assets/e57728f4-fb63-441f-839c-174eef954b17
## ⚠️ Before you start
+### Combining multiple connections on Windows?
+
+To successfully combine bandwidth across multiple network adapters on Windows:
+
+1. **Use distinct internet connections:**
+ - Each connection must have its own gateway / subnet (e.g., **Wi-Fi** via home router + **USB Tethering** via mobile phone, or two distinct WAN networks).
+ - Connecting both Wi-Fi and Ethernet to the **same router** (same local subnet like `192.168.1.0/24`) will not increase speeds: both share the same upstream broadband connection, and Windows routing will send all packets through whichever interface has the lower metric (usually Ethernet).
+2. **Prevent Windows from disconnecting Wi-Fi when Ethernet is plugged in:**
+ - Some Windows 10/11 installations automatically disconnect or sleep Wi-Fi when an active Ethernet cable is detected.
+ - If Wi-Fi turns off when Ethernet is plugged in: open **Group Policy Editor** (`gpedit.msc`) → _Computer Configuration_ → _Administrative Templates_ → _Network_ → _Windows Connection Manager_ → set **"Minimize the number of simultaneous connections to the Internet or a Windows domain"** to **Disabled**.
+
### Using Android USB tethering on macOS?
macOS does not natively provide an RNDIS driver, so Android phones with USB tethering enabled won't appear as network interfaces out of the box (this is also why legacy kernel extensions like `HoRNDIS` stopped working on Apple Silicon and modern macOS).
diff --git a/src/main/network/interfaces.ts b/src/main/network/interfaces.ts
index 780670b..a85b63e 100644
--- a/src/main/network/interfaces.ts
+++ b/src/main/network/interfaces.ts
@@ -78,6 +78,26 @@ async function getWindowsAdapters(): Promise<Map<string, WindowsAdapter>> {
}
}
+/** Computes the CIDR subnet (e.g. "192.168.1.0/24") from an IPv4 address and netmask. */
+export function ipv4Subnet(address: string, netmask: string): string | null {
+ const ipParts = address.split('.').map(Number)
+ const maskParts = netmask.split('.').map(Number)
+ if (ipParts.length !== 4 || maskParts.length !== 4) return null
+ if (
+ ipParts.some((p) => isNaN(p) || p < 0 || p > 255) ||
+ maskParts.some((p) => isNaN(p) || p < 0 || p > 255)
+ ) {
+ return null
+ }
+ const subnetParts = ipParts.map((part, i) => part & maskParts[i])
+ const maskBits =
+ maskParts
+ .map((b) => b.toString(2).padStart(8, '0'))
+ .join('')
+ .split('1').length - 1
+ return `${subnetParts.join('.')}/${maskBits}`
+}
+
/**
* Active non-loopback IPv4 interfaces. Each one has its
* own local IP, which is what lets us bind a download's outgoing connection
@@ -105,13 +125,16 @@ export async function listActiveInterfaces(): Promise<NetworkInterfaceInfo[]> {
// NDIS media: 1 = wireless LAN, 9 = native 802.11, 14 = Ethernet (802.3).
if (adapter?.NdisPhysicalMedium === 1 || adapter?.NdisPhysicalMedium === 9) kind = 'wifi'
else if (kind === 'other' && adapter?.NdisPhysicalMedium === 14) kind = 'ethernet'
+ const subnet = ipv4.netmask ? (ipv4Subnet(ipv4.address, ipv4.netmask) ?? undefined) : undefined
result.push({
id: device,
device,
displayName: hardwareName ?? adapter?.InterfaceDescription ?? device,
address: ipv4.address,
kind,
- mac: ipv4.mac && ipv4.mac !== '00:00:00:00:00:00' ? ipv4.mac : undefined
+ mac: ipv4.mac && ipv4.mac !== '00:00:00:00:00:00' ? ipv4.mac : undefined,
+ subnet,
+ netmask: ipv4.netmask
})
}
diff --git a/src/renderer/src/screens/IdleScreen.tsx b/src/renderer/src/screens/IdleScreen.tsx
index 4835443..4d5f004 100644
--- a/src/renderer/src/screens/IdleScreen.tsx
+++ b/src/renderer/src/screens/IdleScreen.tsx
@@ -1,11 +1,11 @@
import { planDownload } from '@shared/plan'
import type { ProbeResult } from '@shared/types'
import { cn } from 'cn'
-import { AlertTriangle, ClipboardPaste } from 'lucide-react'
+import { AlertTriangle, ClipboardPaste, Info } from 'lucide-react'
import { useEffect, useRef, useState } from 'react'
import { NetworkCard } from '../components/NetworkCard'
import { ScreenFooter } from '../components/ScreenFooter'
-import { Alert, AlertDescription } from '../components/ui/alert'
+import { Alert, AlertDescription, AlertTitle } from '../components/ui/alert'
import { Button } from '../components/ui/button'
import { ToggleGroup, ToggleGroupItem } from '../components/ui/toggle-group'
import { useNetworkPolling } from '../hooks/useNetworkPolling'
@@ -33,6 +33,30 @@ function ErrorAlert({ message }: { message: string }): React.JSX.Element {
)
}
+function WarningAlert({ title, message }: { title?: string; message: string }): React.JSX.Element {
+ return (
+ <Alert className="border-amber-500/40 bg-amber-500/10 text-amber-700 dark:text-amber-300 py-2">
+ <AlertTriangle className="text-amber-600 dark:text-amber-400" />
+ {title && <AlertTitle className="text-xs font-semibold">{title}</AlertTitle>}
+ <AlertDescription className="text-xs text-amber-800 dark:text-amber-200/90 leading-relaxed">
+ {message}
+ </AlertDescription>
+ </Alert>
+ )
+}
+
+function InfoAlert({ title, message }: { title?: string; message: string }): React.JSX.Element {
+ return (
+ <Alert className="border-blue-500/40 bg-blue-500/10 text-blue-700 dark:text-blue-300 py-2">
+ <Info className="text-blue-600 dark:text-blue-400" />
+ {title && <AlertTitle className="text-xs font-semibold">{title}</AlertTitle>}
+ <AlertDescription className="text-xs text-blue-800 dark:text-blue-200/90 leading-relaxed">
+ {message}
+ </AlertDescription>
+ </Alert>
+ )
+}
+
export function IdleScreen(): React.JSX.Element {
useNetworkPolling(true)
@@ -121,6 +145,25 @@ export function IdleScreen(): React.JSX.Element {
}
if (ready && ready.totalBytes !== null) footerParts.push(formatBytes(ready.totalBytes))
+ let subnetConflict: { subnet: string; names: string[] } | null = null
+ if (selectedInterfaceIds.length > 1) {
+ const subnets = new Map<string, string[]>()
+ for (const id of selectedInterfaceIds) {
+ const iface = interfaces.find((i) => i.id === id)
+ if (iface?.subnet) {
+ const names = subnets.get(iface.subnet) ?? []
+ names.push(iface.displayName)
+ subnets.set(iface.subnet, names)
+ }
+ }
+ for (const [subnet, names] of subnets.entries()) {
+ if (names.length > 1) {
+ subnetConflict = { subnet, names }
+ break
+ }
+ }
+ }
+
const handleToggleInterface = (id: string): void => {
if (isSingleStreamOnly) {
// Single-stream mode can only download through 1 interface at a time
@@ -222,6 +265,20 @@ export function IdleScreen(): React.JSX.Element {
{probe.status === 'error' && <ErrorAlert message={probe.message} />}
+ {isSingleStreamOnly && (
+ <InfoAlert
+ title="Single-connection mode"
+ message="This server does not support parallel range requests (206 Partial Content). The download will run as a single stream through whichever network you choose below."
+ />
+ )}
+
+ {subnetConflict && (
+ <WarningAlert
+ title="Same local network detected"
+ message={`${subnetConflict.names.join(' and ')} are connected to the same subnet (${subnetConflict.subnet}). Windows routes all traffic through one connection on the same subnet, so speeds cannot be combined. Connect to distinct networks (e.g. Wi-Fi + phone USB tethering) to combine bandwidth.`}
+ />
+ )}
+
<div
className={cn(
'flex h-9 items-center gap-[9px] rounded-[9px] border px-3',
@@ -318,12 +375,6 @@ export function IdleScreen(): React.JSX.Element {
</div>
</div>
- {isSingleStreamOnly && (
- <div className="text-[11.5px] text-muted-foreground">
- This server doesn’t support multi-chunk downloads for this file — using a single
- network.
- </div>
- )}
{startError && <ErrorAlert message={startError} />}
</div>
diff --git a/src/shared/types.ts b/src/shared/types.ts
index 198f45c..03a8b15 100644
--- a/src/shared/types.ts
+++ b/src/shared/types.ts
@@ -10,6 +10,8 @@ export interface NetworkInterfaceInfo {
address: string
kind: NetworkInterfaceKind
mac?: string
+ subnet?: string
+ netmask?: string
}
export interface ProbeResult {