feat: add I2P BitTorrent engine, DHT, and Firefox torrent extension
- 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:
1 parent
14eae00f5c
commit
fbe6818c4e
37 files changed
+8543
-9
No files matched your search
@@ -326,3 +326,30 @@ test "Streaming caches offline transient key from SYN-ACK to verify CLOSE withou
|
||||
assert_eq(a_stream.read_available(), b"HTTP/1.0 200 OK\r\n\r\nhi")
|
||||
assert_eq(a_stream.is_eof(), true)
|
||||
}
|
||||
|
||||
///|
|
||||
test "StreamManager dispatches protocol 17 repliable and protocol 18 raw datagrams with ports" {
|
||||
let (alice_dest, alice_seed) = make_test_identity(b'\x61')
|
||||
let (bob_dest, bob_seed) = make_test_identity(b'\x62')
|
||||
let bob_mgr = @streaming.StreamManager::new(bob_dest, bob_seed)
|
||||
let rep = @streaming.RepliableDatagram::sign_ed25519(
|
||||
alice_dest, alice_seed, b"dht-query",
|
||||
)
|
||||
let _ = bob_mgr.handle_incoming_i2cp(
|
||||
rep.to_i2cp_bytes(from_port=6881U, to_port=6881U),
|
||||
100UL,
|
||||
)
|
||||
assert_eq(bob_mgr.incoming_datagrams.length(), 1)
|
||||
assert_eq(bob_mgr.incoming_repliable_dgrams.length(), 1)
|
||||
assert_eq(bob_mgr.incoming_repliable_dgrams[0].0.from_port, 6881U)
|
||||
assert_eq(bob_mgr.incoming_repliable_dgrams[0].0.to_port, 6881U)
|
||||
assert_eq(bob_mgr.incoming_repliable_dgrams[0].1.payload, b"dht-query")
|
||||
|
||||
let _ = bob_mgr.handle_incoming_i2cp(
|
||||
@streaming.encode_raw_datagram(b"dht-reply", from_port=6882U, to_port=6882U),
|
||||
101UL,
|
||||
)
|
||||
assert_eq(bob_mgr.incoming_raw_dgrams.length(), 1)
|
||||
assert_eq(bob_mgr.incoming_raw_dgrams[0].0.from_port, 6882U)
|
||||
assert_eq(bob_mgr.incoming_raw_dgrams[0].1, b"dht-reply")
|
||||
}
|
||||
Reference in new issue
Block a user