Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

How I Built a Pure-Dart SSTP & PPP VPN Client From Scratch

说明与用途

使用纯 Dart 构建的 VPN 客户端,实现 SSTP 与 PPP,并支持跨平台 TUN 路由及 Apple Silicon ABI 修复。

问题

Developers want a cross‑platform VPN client written entirely in Dart, avoiding native binaries and enabling low‑level networking in a high‑level language.

结果

The sstp_client library demonstrates that a pure‑Dart implementation can handle complex VPN protocols, cross‑platform TUN routing, and low‑level FFI bugs, all while remaining fully unit‑tested offline.

工作流

  • 1. Spin up a dart:io SecureSocket and perform an HTTP SSTP_DUPLEX_POST to establish the tunnel.
  • 2. Use SstpFramer to reassemble incoming bytes into SSTP control frames or raw data.
  • 3. Run the SSTP state machine (SstpSession) to negotiate PPP: LCP → MSCHAPv2 → IPCP.
  • 4. Create a virtual network interface via platform‑specific backends (Linux /dev/net/tun, Windows Wintun, macOS utun).
  • 5. Strip or prepend the 4‑byte address family header on macOS.
  • 6. Spawn a dedicated Dart Isolate per backend to perform blocking reads from the kernel/driver and send packets back to the main event loop via SendPort.
  • 7. Apply the Apple Silicon fix by declaring ioctl with VarArgs for Darwin targets.
  • 8. On disconnect, restore original routing tables instantly.

证据

The client successfully handles full‑tunnel and split‑tunnel routing over IPv4 with robust cleanups that restore your system's original routes instantly upon disconnect.

来源

The core stack is fully unit‑tested entirely offline using mocked crypto vectors (RFC 2759) and synthetic pipes—no root permissions or live servers required to verify the code integrity.

来源

  • 记录日期: 2026-09-14T05:30:54.298Z