feat: add I2P BitTorrent engine, DHT, and Firefox torrent extension
check / check (macos-latest) (push) Failing after 29s
check / check (ubuntu-latest) (push) Failing after 29s
check / check (windows-latest) (push) Failing after 30s

- Add pure-MoonBit bittorrent package: bencode codec, metainfo/magnet parsing with path traversal checks, peer wire protocol (BEP 10/9), and I2P Kademlia DHT with KRPC and 54-byte compact nodes
- Add SHA-1 primitive in crypto for torrent info hashes
- Add router torrent API and engine, enabled with --torrent-api (default 127.0.0.1:4445) and --download-dir
- Add Firefox WebExtension torrent manager with native messaging host and packed .xpi
- Add scripts to build a standalone Firefox + router AppImage and install the native host
- Add just targets (proxy, appimage, extension), README docs, and ignore .cache/ and dist/
This commit is contained in:
nandi committed 2026-11-28 13:19:03 -08:00
1 parent 14eae00f5c
commit fbe6818c4e
37 files changed
+8543 -9

No files matched your search

+25
View File
@@ -71,6 +71,9 @@ pub struct Router {
priv mut http_proxy_listener : @ntcp2_net.TcpListener?
priv http_proxy_conns : Array[HttpProxyConn]
priv mut http_proxy_session_id : String?
priv mut torrent_engine : TorrentEngine?
priv mut torrent_api_listener : @ntcp2_net.TcpListener?
priv torrent_api_conns : Array[TorrentApiConn]
priv mut lease_rr : Int32
priv mut outbound_rr : Int32
priv mut last_bootstrap_ms : UInt64
@@ -263,6 +266,9 @@ pub fn Router::start(
http_proxy_listener: None,
http_proxy_conns: [],
http_proxy_session_id: None,
torrent_engine: None,
torrent_api_listener: None,
torrent_api_conns: [],
lease_rr: 0,
outbound_rr: 0,
last_bootstrap_ms: 0UL,
@@ -432,6 +438,19 @@ pub fn Router::reseed_from_url(
///|
pub fn Router::close(self : Router) -> Unit {
for ac in self.torrent_api_conns {
if !ac.closed {
ac.sock.close()
ac.closed = true
}
}
match self.torrent_api_listener {
Some(l) => {
l.close()
self.torrent_api_listener = None
}
None => ()
}
for pc in self.http_proxy_conns {
if !pc.closed {
pc.sock.close()
@@ -564,6 +583,12 @@ pub fn Router::step(self : Router, poll_ms~ : Int32 = 10) -> Unit {
if self.step_http_proxy() {
did_work = true
}
if self.step_torrent_engine() {
did_work = true
}
if self.step_torrent_api() {
did_work = true
}
self.poll_netdb_lookups()
self.poll_tunnel_builds()
if self.public_mode {