@push.rocks/smartvpn 1.5.0 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
Binary file
|
|
Binary file
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export const commitinfo = {
|
|
5
5
|
name: '@push.rocks/smartvpn',
|
|
6
|
-
version: '1.
|
|
6
|
+
version: '1.7.0',
|
|
7
7
|
description: 'A VPN solution with TypeScript control plane and Rust data plane daemon'
|
|
8
8
|
};
|
|
9
9
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMDBfY29tbWl0aW5mb19kYXRhLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvMDBfY29tbWl0aW5mb19kYXRhLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOztHQUVHO0FBQ0gsTUFBTSxDQUFDLE1BQU0sVUFBVSxHQUFHO0lBQ3hCLElBQUksRUFBRSxzQkFBc0I7SUFDNUIsT0FBTyxFQUFFLE9BQU87SUFDaEIsV0FBVyxFQUFFLHlFQUF5RTtDQUN2RixDQUFBIn0=
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@push.rocks/smartvpn",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "A VPN solution with TypeScript control plane and Rust data plane daemon",
|
|
6
6
|
"type": "module",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"main": "dist_ts/index.js",
|
|
11
11
|
"typings": "dist_ts/index.d.ts",
|
|
12
12
|
"scripts": {
|
|
13
|
-
"build": "(tsbuild tsfolders
|
|
13
|
+
"build": "(tsbuild tsfolders) && (tsrust)",
|
|
14
14
|
"test:before": "(tsrust)",
|
|
15
15
|
"test": "tstest test/ --verbose",
|
|
16
16
|
"buildDocs": "tsdoc"
|
|
@@ -33,10 +33,10 @@
|
|
|
33
33
|
"@push.rocks/smartrust": "^1.3.2"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@git.zone/tsbuild": "^4.
|
|
37
|
-
"@git.zone/tsrun": "^2.0.
|
|
38
|
-
"@git.zone/tsrust": "^1.3.
|
|
39
|
-
"@git.zone/tstest": "^3.
|
|
36
|
+
"@git.zone/tsbuild": "^4.4.0",
|
|
37
|
+
"@git.zone/tsrun": "^2.0.2",
|
|
38
|
+
"@git.zone/tsrust": "^1.3.2",
|
|
39
|
+
"@git.zone/tstest": "^3.6.3",
|
|
40
40
|
"@types/node": "^25.5.0"
|
|
41
41
|
},
|
|
42
42
|
"files": [
|
package/readme.md
CHANGED
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
A high-performance VPN with a **TypeScript control plane** and a **Rust data plane daemon**. Manage VPN connections with clean, fully-typed APIs while all networking heavy lifting — encryption, tunneling, QoS, rate limiting — runs at native speed in Rust.
|
|
4
4
|
|
|
5
|
-
🔒 **Noise NK** handshake + **XChaCha20-Poly1305** encryption
|
|
6
|
-
🚀 **
|
|
7
|
-
📊 **Adaptive QoS**: packet classification, priority queues, per-client rate limiting
|
|
8
|
-
🔄 **Auto-transport**: tries QUIC first, falls back to WebSocket seamlessly
|
|
9
|
-
📡 **Real-time telemetry**: RTT, jitter, loss, link health — all exposed via typed APIs
|
|
5
|
+
🔒 **Noise NK** handshake + **XChaCha20-Poly1305** encryption
|
|
6
|
+
🚀 **Triple transport**: WebSocket (Cloudflare-friendly), raw **QUIC** (datagrams), and **WireGuard** (standard protocol)
|
|
7
|
+
📊 **Adaptive QoS**: packet classification, priority queues, per-client rate limiting
|
|
8
|
+
🔄 **Auto-transport**: tries QUIC first, falls back to WebSocket seamlessly
|
|
9
|
+
📡 **Real-time telemetry**: RTT, jitter, loss, link health — all exposed via typed APIs
|
|
10
|
+
🛡️ **WireGuard mode**: full userspace WireGuard via `boringtun` — generate `.conf` files, manage peers live
|
|
10
11
|
|
|
11
12
|
## Issue Reporting and Security
|
|
12
13
|
|
|
@@ -27,9 +28,10 @@ TypeScript (control plane) Rust (data plane)
|
|
|
27
28
|
│ └─ VpnBridge │──stdio/──▶ │ ├─ management (JSON IPC) │
|
|
28
29
|
│ └─ RustBridge │ socket │ ├─ transport_trait (abstraction) │
|
|
29
30
|
│ (smartrust) │ │ │ ├─ transport (WebSocket/TLS) │
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
│ │ │ │ └─ quic_transport (QUIC/UDP) │
|
|
32
|
+
│ WgConfigGenerator │ │ ├─ wireguard (boringtun WG) │
|
|
33
|
+
│ └─ .conf file output │ │ ├─ crypto (Noise NK + XCha20) │
|
|
34
|
+
└──────────────────────────┘ │ ├─ codec (binary framing) │
|
|
33
35
|
│ ├─ keepalive (adaptive state FSM) │
|
|
34
36
|
│ ├─ telemetry (RTT/jitter/loss) │
|
|
35
37
|
│ ├─ qos (classify + priority Q) │
|
|
@@ -45,8 +47,9 @@ TypeScript (control plane) Rust (data plane)
|
|
|
45
47
|
|
|
46
48
|
| Decision | Choice | Why |
|
|
47
49
|
|----------|--------|-----|
|
|
48
|
-
| Transport | WebSocket + QUIC
|
|
50
|
+
| Transport | WebSocket + QUIC + WireGuard | WS works through Cloudflare; QUIC gives low latency + datagrams; WG for standard protocol interop |
|
|
49
51
|
| Auto-transport | QUIC first, WS fallback | Best performance when QUIC is available, graceful degradation when it's not |
|
|
52
|
+
| WireGuard | Userspace via `boringtun` | No kernel module needed, runs on any platform, full peer management via IPC |
|
|
50
53
|
| Encryption | Noise NK + XChaCha20-Poly1305 | Strong forward secrecy, large nonce space (no counter sync needed) |
|
|
51
54
|
| QUIC auth | Certificate hash pinning | WireGuard-style trust model — no CA needed, just pin the server cert hash |
|
|
52
55
|
| Keepalive | Adaptive app-level pings | Cloudflare drops WS pings; interval adapts to link health (10–60s) |
|
|
@@ -132,6 +135,37 @@ await autoClient.connect({
|
|
|
132
135
|
});
|
|
133
136
|
```
|
|
134
137
|
|
|
138
|
+
### VPN Client with WireGuard
|
|
139
|
+
|
|
140
|
+
```typescript
|
|
141
|
+
import { VpnClient } from '@push.rocks/smartvpn';
|
|
142
|
+
|
|
143
|
+
const wgClient = new VpnClient({
|
|
144
|
+
transport: { transport: 'stdio' },
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
await wgClient.start();
|
|
148
|
+
|
|
149
|
+
const { assignedIp } = await wgClient.connect({
|
|
150
|
+
serverPublicKey: 'BASE64_SERVER_WG_PUBLIC_KEY',
|
|
151
|
+
serverUrl: '', // not used for WireGuard
|
|
152
|
+
transport: 'wireguard',
|
|
153
|
+
wgPrivateKey: 'BASE64_CLIENT_PRIVATE_KEY',
|
|
154
|
+
wgAddress: '10.8.0.2',
|
|
155
|
+
wgAddressPrefix: 24,
|
|
156
|
+
wgEndpoint: 'vpn.example.com:51820',
|
|
157
|
+
wgAllowedIps: ['0.0.0.0/0'], // route all traffic
|
|
158
|
+
wgPersistentKeepalive: 25,
|
|
159
|
+
wgPresharedKey: 'OPTIONAL_PSK', // optional extra layer
|
|
160
|
+
dns: ['1.1.1.1'],
|
|
161
|
+
mtu: 1420,
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
console.log(`WireGuard connected! IP: ${assignedIp}`);
|
|
165
|
+
await wgClient.disconnect();
|
|
166
|
+
wgClient.stop();
|
|
167
|
+
```
|
|
168
|
+
|
|
135
169
|
### VPN Server
|
|
136
170
|
|
|
137
171
|
```typescript
|
|
@@ -154,7 +188,7 @@ await server.start({
|
|
|
154
188
|
dns: ['1.1.1.1'],
|
|
155
189
|
mtu: 1420,
|
|
156
190
|
enableNat: true,
|
|
157
|
-
// Transport mode: 'websocket', 'quic', or '
|
|
191
|
+
// Transport mode: 'websocket', 'quic', 'both', or 'wireguard'
|
|
158
192
|
transportMode: 'both',
|
|
159
193
|
// Optional: separate QUIC listen address
|
|
160
194
|
quicListenAddr: '0.0.0.0:4433',
|
|
@@ -188,6 +222,125 @@ await server.stopServer();
|
|
|
188
222
|
server.stop();
|
|
189
223
|
```
|
|
190
224
|
|
|
225
|
+
### WireGuard Server Mode
|
|
226
|
+
|
|
227
|
+
```typescript
|
|
228
|
+
import { VpnServer } from '@push.rocks/smartvpn';
|
|
229
|
+
|
|
230
|
+
const wgServer = new VpnServer({
|
|
231
|
+
transport: { transport: 'stdio' },
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
// Generate a WireGuard X25519 keypair
|
|
235
|
+
await wgServer.start();
|
|
236
|
+
const keypair = await wgServer.generateWgKeypair();
|
|
237
|
+
console.log(`Server public key: ${keypair.publicKey}`);
|
|
238
|
+
|
|
239
|
+
// Start in WireGuard mode
|
|
240
|
+
await wgServer.start({
|
|
241
|
+
listenAddr: '0.0.0.0:51820',
|
|
242
|
+
privateKey: keypair.privateKey,
|
|
243
|
+
publicKey: keypair.publicKey,
|
|
244
|
+
subnet: '10.8.0.0/24',
|
|
245
|
+
transportMode: 'wireguard',
|
|
246
|
+
wgListenPort: 51820,
|
|
247
|
+
wgPeers: [
|
|
248
|
+
{
|
|
249
|
+
publicKey: 'CLIENT_PUBLIC_KEY_BASE64',
|
|
250
|
+
allowedIps: ['10.8.0.2/32'],
|
|
251
|
+
persistentKeepalive: 25,
|
|
252
|
+
},
|
|
253
|
+
],
|
|
254
|
+
enableNat: true,
|
|
255
|
+
dns: ['1.1.1.1'],
|
|
256
|
+
mtu: 1420,
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
// Live peer management — add/remove peers without restart
|
|
260
|
+
await wgServer.addWgPeer({
|
|
261
|
+
publicKey: 'NEW_CLIENT_PUBLIC_KEY',
|
|
262
|
+
allowedIps: ['10.8.0.3/32'],
|
|
263
|
+
persistentKeepalive: 25,
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
// List peers with live stats
|
|
267
|
+
const peers = await wgServer.listWgPeers();
|
|
268
|
+
for (const peer of peers) {
|
|
269
|
+
console.log(`${peer.publicKey}: ↑${peer.bytesSent} ↓${peer.bytesReceived}`);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
// Remove a peer by public key
|
|
273
|
+
await wgServer.removeWgPeer('CLIENT_PUBLIC_KEY_BASE64');
|
|
274
|
+
|
|
275
|
+
await wgServer.stopServer();
|
|
276
|
+
wgServer.stop();
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
### Generating WireGuard .conf Files
|
|
280
|
+
|
|
281
|
+
The `WgConfigGenerator` creates standard WireGuard `.conf` files compatible with `wg-quick`, iOS/Android apps, and all standard WireGuard clients:
|
|
282
|
+
|
|
283
|
+
```typescript
|
|
284
|
+
import { WgConfigGenerator } from '@push.rocks/smartvpn';
|
|
285
|
+
|
|
286
|
+
// Client config (for wg-quick or mobile apps)
|
|
287
|
+
const clientConf = WgConfigGenerator.generateClientConfig({
|
|
288
|
+
privateKey: 'CLIENT_PRIVATE_KEY_BASE64',
|
|
289
|
+
address: '10.8.0.2/24',
|
|
290
|
+
dns: ['1.1.1.1', '8.8.8.8'],
|
|
291
|
+
mtu: 1420,
|
|
292
|
+
peer: {
|
|
293
|
+
publicKey: 'SERVER_PUBLIC_KEY_BASE64',
|
|
294
|
+
endpoint: 'vpn.example.com:51820',
|
|
295
|
+
allowedIps: ['0.0.0.0/0', '::/0'],
|
|
296
|
+
persistentKeepalive: 25,
|
|
297
|
+
presharedKey: 'OPTIONAL_PSK_BASE64',
|
|
298
|
+
},
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
// Server config (for wg-quick)
|
|
302
|
+
const serverConf = WgConfigGenerator.generateServerConfig({
|
|
303
|
+
privateKey: 'SERVER_PRIVATE_KEY_BASE64',
|
|
304
|
+
address: '10.8.0.1/24',
|
|
305
|
+
listenPort: 51820,
|
|
306
|
+
dns: ['1.1.1.1'],
|
|
307
|
+
mtu: 1420,
|
|
308
|
+
enableNat: true,
|
|
309
|
+
natInterface: 'eth0', // auto-detected if omitted
|
|
310
|
+
peers: [
|
|
311
|
+
{
|
|
312
|
+
publicKey: 'CLIENT_PUBLIC_KEY_BASE64',
|
|
313
|
+
allowedIps: ['10.8.0.2/32'],
|
|
314
|
+
persistentKeepalive: 25,
|
|
315
|
+
},
|
|
316
|
+
],
|
|
317
|
+
});
|
|
318
|
+
|
|
319
|
+
// Write to disk
|
|
320
|
+
import * as fs from 'fs';
|
|
321
|
+
fs.writeFileSync('/etc/wireguard/wg0.conf', serverConf);
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
<details>
|
|
325
|
+
<summary>Example output: client .conf</summary>
|
|
326
|
+
|
|
327
|
+
```ini
|
|
328
|
+
[Interface]
|
|
329
|
+
PrivateKey = CLIENT_PRIVATE_KEY_BASE64
|
|
330
|
+
Address = 10.8.0.2/24
|
|
331
|
+
DNS = 1.1.1.1, 8.8.8.8
|
|
332
|
+
MTU = 1420
|
|
333
|
+
|
|
334
|
+
[Peer]
|
|
335
|
+
PublicKey = SERVER_PUBLIC_KEY_BASE64
|
|
336
|
+
PresharedKey = OPTIONAL_PSK_BASE64
|
|
337
|
+
Endpoint = vpn.example.com:51820
|
|
338
|
+
AllowedIPs = 0.0.0.0/0, ::/0
|
|
339
|
+
PersistentKeepalive = 25
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
</details>
|
|
343
|
+
|
|
191
344
|
### Production: Socket Transport
|
|
192
345
|
|
|
193
346
|
In production, the daemon runs as a system service and you connect over a Unix socket:
|
|
@@ -216,7 +369,7 @@ When using socket transport, `client.stop()` closes the socket but **does not ki
|
|
|
216
369
|
| Method | Returns | Description |
|
|
217
370
|
|--------|---------|-------------|
|
|
218
371
|
| `start()` | `Promise<boolean>` | Start the daemon bridge (spawn or connect) |
|
|
219
|
-
| `connect(config?)` | `Promise<{ assignedIp }>` | Connect to VPN server |
|
|
372
|
+
| `connect(config?)` | `Promise<{ assignedIp }>` | Connect to VPN server (WS, QUIC, or WireGuard) |
|
|
220
373
|
| `disconnect()` | `Promise<void>` | Disconnect from VPN |
|
|
221
374
|
| `getStatus()` | `Promise<IVpnStatus>` | Current connection state |
|
|
222
375
|
| `getStatistics()` | `Promise<IVpnStatistics>` | Traffic stats + connection quality |
|
|
@@ -239,6 +392,10 @@ When using socket transport, `client.stop()` closes the socket but **does not ki
|
|
|
239
392
|
| `setClientRateLimit(id, rate, burst)` | `Promise<void>` | Set per-client rate limit (bytes/sec) |
|
|
240
393
|
| `removeClientRateLimit(id)` | `Promise<void>` | Remove rate limit (unlimited) |
|
|
241
394
|
| `getClientTelemetry(id)` | `Promise<IVpnClientTelemetry>` | Per-client telemetry + drop stats |
|
|
395
|
+
| `generateWgKeypair()` | `Promise<IVpnKeypair>` | Generate WireGuard X25519 keypair |
|
|
396
|
+
| `addWgPeer(peer)` | `Promise<void>` | Add a WireGuard peer at runtime |
|
|
397
|
+
| `removeWgPeer(publicKey)` | `Promise<void>` | Remove a WireGuard peer by key |
|
|
398
|
+
| `listWgPeers()` | `Promise<IWgPeerInfo[]>` | List WG peers with traffic stats |
|
|
242
399
|
| `stop()` | `void` | Kill/close the daemon bridge |
|
|
243
400
|
|
|
244
401
|
### `VpnConfig`
|
|
@@ -257,6 +414,19 @@ const config = await VpnConfig.loadFromFile<IVpnClientConfig>('/etc/smartvpn/cli
|
|
|
257
414
|
await VpnConfig.saveToFile('/etc/smartvpn/client.json', config);
|
|
258
415
|
```
|
|
259
416
|
|
|
417
|
+
Validation covers both smartvpn-native configs and WireGuard configs — base64 key format, CIDR ranges, port ranges, and required fields are all checked.
|
|
418
|
+
|
|
419
|
+
### `WgConfigGenerator`
|
|
420
|
+
|
|
421
|
+
Static generator for standard WireGuard `.conf` files:
|
|
422
|
+
|
|
423
|
+
| Method | Returns | Description |
|
|
424
|
+
|--------|---------|-------------|
|
|
425
|
+
| `generateClientConfig(opts)` | `string` | Generate a `wg-quick` compatible client `.conf` |
|
|
426
|
+
| `generateServerConfig(opts)` | `string` | Generate a `wg-quick` compatible server `.conf` with NAT rules |
|
|
427
|
+
|
|
428
|
+
Output is compatible with `wg-quick`, WireGuard iOS/Android apps, and any standard WireGuard implementation.
|
|
429
|
+
|
|
260
430
|
### `VpnInstaller`
|
|
261
431
|
|
|
262
432
|
Generate system service units for the daemon:
|
|
@@ -306,9 +476,9 @@ server.on('stopped', () => { /* server listener stopped */ });
|
|
|
306
476
|
|
|
307
477
|
## 🌐 Transport Modes
|
|
308
478
|
|
|
309
|
-
smartvpn supports
|
|
479
|
+
smartvpn supports three transport protocols. The smartvpn-native transports (WebSocket + QUIC) share the same encryption, framing, and QoS pipeline. WireGuard mode uses the standard WireGuard protocol for broad interoperability.
|
|
310
480
|
|
|
311
|
-
### WebSocket (default)
|
|
481
|
+
### WebSocket (default for smartvpn-native)
|
|
312
482
|
|
|
313
483
|
- Works through Cloudflare, reverse proxies, and HTTP load balancers
|
|
314
484
|
- Reliable delivery only (no datagram support)
|
|
@@ -322,7 +492,17 @@ smartvpn supports two transport protocols through a unified transport abstractio
|
|
|
322
492
|
- URL format: `host:port`
|
|
323
493
|
- ALPN protocol: `smartvpn`
|
|
324
494
|
|
|
325
|
-
###
|
|
495
|
+
### WireGuard
|
|
496
|
+
|
|
497
|
+
- Standard WireGuard protocol via `boringtun` (userspace, no kernel module)
|
|
498
|
+
- Compatible with **all WireGuard clients** — iOS, Android, macOS, Windows, Linux, routers
|
|
499
|
+
- X25519 key exchange, ChaCha20-Poly1305 encryption
|
|
500
|
+
- Dynamic peer management at runtime (add/remove without restart)
|
|
501
|
+
- Optional preshared keys for post-quantum defense-in-depth
|
|
502
|
+
- Generate `.conf` files for standard clients via `WgConfigGenerator`
|
|
503
|
+
- Default port: `51820/UDP`
|
|
504
|
+
|
|
505
|
+
### Auto-Transport (Recommended for smartvpn-native)
|
|
326
506
|
|
|
327
507
|
The default `transport: 'auto'` mode gives you the best of both worlds:
|
|
328
508
|
|
|
@@ -339,16 +519,26 @@ await client.connect({
|
|
|
339
519
|
});
|
|
340
520
|
```
|
|
341
521
|
|
|
342
|
-
### Server Dual-Mode
|
|
522
|
+
### Server Dual-Mode / Multi-Mode
|
|
343
523
|
|
|
344
|
-
The server can listen on
|
|
524
|
+
The server can listen on multiple transports simultaneously:
|
|
345
525
|
|
|
346
526
|
```typescript
|
|
527
|
+
// WebSocket + QUIC (dual mode)
|
|
347
528
|
await server.start({
|
|
348
529
|
listenAddr: '0.0.0.0:443', // WebSocket listener
|
|
349
530
|
quicListenAddr: '0.0.0.0:4433', // QUIC listener (optional, defaults to listenAddr)
|
|
350
|
-
transportMode: 'both', // 'websocket' | 'quic' | 'both'
|
|
351
|
-
quicIdleTimeoutSecs: 30,
|
|
531
|
+
transportMode: 'both', // 'websocket' | 'quic' | 'both' | 'wireguard'
|
|
532
|
+
quicIdleTimeoutSecs: 30,
|
|
533
|
+
// ... other config
|
|
534
|
+
});
|
|
535
|
+
|
|
536
|
+
// WireGuard standalone
|
|
537
|
+
await server.start({
|
|
538
|
+
listenAddr: '0.0.0.0:51820',
|
|
539
|
+
transportMode: 'wireguard',
|
|
540
|
+
wgListenPort: 51820,
|
|
541
|
+
wgPeers: [{ publicKey: '...', allowedIps: ['10.8.0.2/32'] }],
|
|
352
542
|
// ... other config
|
|
353
543
|
});
|
|
354
544
|
```
|
|
@@ -428,6 +618,8 @@ For a standard 1500-byte Ethernet link, effective TUN MTU = **1421 bytes**. The
|
|
|
428
618
|
|
|
429
619
|
## 🔐 Security Model
|
|
430
620
|
|
|
621
|
+
### smartvpn-native (WebSocket / QUIC)
|
|
622
|
+
|
|
431
623
|
The VPN uses a **Noise NK** handshake pattern:
|
|
432
624
|
|
|
433
625
|
1. **NK** = client does **N**ot authenticate, but **K**nows the server's static public key
|
|
@@ -440,6 +632,14 @@ Post-handshake, all IP packets are encrypted with **XChaCha20-Poly1305**:
|
|
|
440
632
|
- 16-byte authentication tags
|
|
441
633
|
- Wire format: `[nonce:24B][ciphertext:var][tag:16B]`
|
|
442
634
|
|
|
635
|
+
### WireGuard Mode
|
|
636
|
+
|
|
637
|
+
Uses the standard [Noise IKpsk2](https://www.wireguard.com/protocol/) handshake:
|
|
638
|
+
- **X25519** key exchange (Curve25519 Diffie-Hellman)
|
|
639
|
+
- **ChaCha20-Poly1305** AEAD encryption
|
|
640
|
+
- Optional **preshared keys** for post-quantum defense-in-depth
|
|
641
|
+
- Implemented via `boringtun` — Cloudflare's userspace WireGuard in Rust
|
|
642
|
+
|
|
443
643
|
### QUIC Certificate Pinning
|
|
444
644
|
|
|
445
645
|
When using QUIC transport, the server generates a self-signed TLS certificate (or uses a configured PEM). Instead of relying on a CA chain, clients pin the server's certificate by its **SHA-256 hash** (base64-encoded) — a WireGuard-inspired trust model:
|
|
@@ -481,6 +681,8 @@ Inside the tunnel (both WebSocket and QUIC reliable channels), packets use a sim
|
|
|
481
681
|
|
|
482
682
|
When QUIC datagrams are available, IP packets can optionally be sent via the unreliable datagram channel for lower latency. Packets that exceed the max datagram size automatically fall back to the reliable stream.
|
|
483
683
|
|
|
684
|
+
> **Note:** WireGuard mode uses the standard WireGuard wire protocol, not this binary framing.
|
|
685
|
+
|
|
484
686
|
## 🛠️ Rust Daemon CLI
|
|
485
687
|
|
|
486
688
|
```bash
|
|
@@ -507,7 +709,7 @@ pnpm build
|
|
|
507
709
|
# Build Rust only (debug)
|
|
508
710
|
cd rust && cargo build
|
|
509
711
|
|
|
510
|
-
# Run all tests (
|
|
712
|
+
# Run all tests (93 Rust + 77 TypeScript)
|
|
511
713
|
cd rust && cargo test
|
|
512
714
|
pnpm test
|
|
513
715
|
```
|
|
@@ -533,12 +735,20 @@ type TVpnTransportOptions =
|
|
|
533
735
|
// Client config
|
|
534
736
|
interface IVpnClientConfig {
|
|
535
737
|
serverUrl: string; // WS: 'wss://host/path' | QUIC: 'host:port'
|
|
536
|
-
serverPublicKey: string; // Base64-encoded Noise static key
|
|
537
|
-
transport?: 'auto' | 'websocket' | 'quic'; // Default: 'auto'
|
|
738
|
+
serverPublicKey: string; // Base64-encoded Noise static key (or WG public key)
|
|
739
|
+
transport?: 'auto' | 'websocket' | 'quic' | 'wireguard'; // Default: 'auto'
|
|
538
740
|
serverCertHash?: string; // SHA-256 cert hash (base64) for QUIC pinning
|
|
539
741
|
dns?: string[];
|
|
540
742
|
mtu?: number;
|
|
541
743
|
keepaliveIntervalSecs?: number;
|
|
744
|
+
// WireGuard-specific
|
|
745
|
+
wgPrivateKey?: string; // Client private key (base64, X25519)
|
|
746
|
+
wgAddress?: string; // Client TUN address (e.g. 10.8.0.2)
|
|
747
|
+
wgAddressPrefix?: number; // Address prefix length (default: 24)
|
|
748
|
+
wgPresharedKey?: string; // Optional preshared key (base64)
|
|
749
|
+
wgPersistentKeepalive?: number; // Persistent keepalive interval (seconds)
|
|
750
|
+
wgEndpoint?: string; // Server endpoint (host:port)
|
|
751
|
+
wgAllowedIps?: string[]; // Allowed IPs (CIDR strings)
|
|
542
752
|
}
|
|
543
753
|
|
|
544
754
|
// Server config
|
|
@@ -553,11 +763,36 @@ interface IVpnServerConfig {
|
|
|
553
763
|
mtu?: number;
|
|
554
764
|
keepaliveIntervalSecs?: number;
|
|
555
765
|
enableNat?: boolean;
|
|
556
|
-
transportMode?: 'websocket' | 'quic' | 'both'
|
|
557
|
-
quicListenAddr?: string;
|
|
558
|
-
quicIdleTimeoutSecs?: number;
|
|
766
|
+
transportMode?: 'websocket' | 'quic' | 'both' | 'wireguard';
|
|
767
|
+
quicListenAddr?: string;
|
|
768
|
+
quicIdleTimeoutSecs?: number;
|
|
559
769
|
defaultRateLimitBytesPerSec?: number;
|
|
560
770
|
defaultBurstBytes?: number;
|
|
771
|
+
// WireGuard-specific
|
|
772
|
+
wgListenPort?: number; // UDP port (default: 51820)
|
|
773
|
+
wgPeers?: IWgPeerConfig[]; // Initial peers
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
// WireGuard peer config
|
|
777
|
+
interface IWgPeerConfig {
|
|
778
|
+
publicKey: string; // Peer's X25519 public key (base64)
|
|
779
|
+
presharedKey?: string; // Optional preshared key (base64)
|
|
780
|
+
allowedIps: string[]; // Allowed IP ranges (CIDR)
|
|
781
|
+
endpoint?: string; // Peer endpoint (host:port)
|
|
782
|
+
persistentKeepalive?: number; // Keepalive interval (seconds)
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
// WireGuard peer info (with live stats)
|
|
786
|
+
interface IWgPeerInfo {
|
|
787
|
+
publicKey: string;
|
|
788
|
+
allowedIps: string[];
|
|
789
|
+
endpoint?: string;
|
|
790
|
+
persistentKeepalive?: number;
|
|
791
|
+
bytesSent: number;
|
|
792
|
+
bytesReceived: number;
|
|
793
|
+
packetsSent: number;
|
|
794
|
+
packetsReceived: number;
|
|
795
|
+
lastHandshakeTime?: string;
|
|
561
796
|
}
|
|
562
797
|
|
|
563
798
|
// Status
|
|
@@ -652,7 +887,7 @@ interface IVpnKeypair {
|
|
|
652
887
|
|
|
653
888
|
## License and Legal Information
|
|
654
889
|
|
|
655
|
-
This repository contains open-source code licensed under the MIT License. A copy of the license can be found in the [LICENSE](./
|
|
890
|
+
This repository contains open-source code licensed under the MIT License. A copy of the license can be found in the [LICENSE](./license.md) file.
|
|
656
891
|
|
|
657
892
|
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
|
|
658
893
|
|