feat: add HTTP-over-I2P proxy to router daemon
- Add --http-proxy/--proxy [host:port] (default 127.0.0.1:4444) to route .i2p and .b32.i2p HTTP requests over I2P streams - Block clearnet hosts with 403 and reject CONNECT and https:// with 501 - Support ?i2paddresshelper= jump links that register host aliases - Add `just proxy` target and -h/--help usage output - Expire idle ratchet sessions after 300s and add RatchetSessionManager::drop_session for fresh NewSession handshakes - Add NetDb::remove_lease_set2 and bound the outbound pending queue to 64 entries
This commit is contained in:
1 parent
54cfb2faa9
commit
14eae00f5c
15 files changed
+1941
-41
No files matched your search
@@ -190,3 +190,111 @@ test "Proposal 144 ECIES-X25519-AEAD-Ratchet NS -> NSR -> bidirectional ES + DH
|
||||
}
|
||||
assert_eq(wrong_failed, true)
|
||||
}
|
||||
|
||||
///|
|
||||
test "Proposal 144 ECIES Ratchet idle session expiry (>300s) and drop_session recovery" {
|
||||
let alice_s = @noise.KeyPair::from_private(@crypto.sha256(b"alice-idle-s"))
|
||||
let bob_s = @noise.KeyPair::from_private(@crypto.sha256(b"bob-idle-s"))
|
||||
let alice_mgr = @ratchet.RatchetSessionManager::new(alice_s)
|
||||
let bob_mgr = @ratchet.RatchetSessionManager::new(bob_s)
|
||||
let rand_a = det_rand_gen(b'\x21')
|
||||
let rand_b = det_rand_gen(b'\x61')
|
||||
|
||||
// Initial NS -> NSR -> ES at t=1700000100
|
||||
let c1 = @ratchet.garlic_clove_block(
|
||||
Local,
|
||||
1U,
|
||||
1700000600U,
|
||||
Data(data=b"init"),
|
||||
)
|
||||
let w1 = alice_mgr.encrypt_to_peer(
|
||||
bob_s.public_key,
|
||||
[c1],
|
||||
1700000100U,
|
||||
rand_a,
|
||||
)
|
||||
let _ = bob_mgr.decrypt_incoming(w1)
|
||||
let c2 = @ratchet.garlic_clove_block(
|
||||
Local,
|
||||
2U,
|
||||
1700000600U,
|
||||
Data(data=b"nsr"),
|
||||
)
|
||||
let w2 = bob_mgr.encrypt_to_peer(
|
||||
alice_s.public_key,
|
||||
[c2],
|
||||
1700000101U,
|
||||
rand_b,
|
||||
)
|
||||
let _ = alice_mgr.decrypt_incoming(w2)
|
||||
|
||||
// Encrypting within window at t=1700000105 uses ExistingSession (accepted by bob_mgr)
|
||||
let c3 = @ratchet.garlic_clove_block(
|
||||
Local,
|
||||
3U,
|
||||
1700000600U,
|
||||
Data(data=b"es-alive"),
|
||||
)
|
||||
let w3 = alice_mgr.encrypt_to_peer(
|
||||
bob_s.public_key,
|
||||
[c3],
|
||||
1700000105U,
|
||||
rand_a,
|
||||
)
|
||||
let (_, dec3) = bob_mgr.decrypt_incoming(w3)
|
||||
assert_eq(dec3, [c3])
|
||||
|
||||
// After >300s idle (t=1700000406 > 1700000105+300), alice initiates a fresh Bound NS
|
||||
// that even a restarted responder with empty session state can decrypt
|
||||
let bob_restarted = @ratchet.RatchetSessionManager::new(bob_s)
|
||||
let c4 = @ratchet.garlic_clove_block(
|
||||
Local,
|
||||
4U,
|
||||
1700000900U,
|
||||
Data(data=b"after-idle"),
|
||||
)
|
||||
let w4 = alice_mgr.encrypt_to_peer(
|
||||
bob_s.public_key,
|
||||
[c4],
|
||||
1700000406U,
|
||||
rand_a,
|
||||
)
|
||||
let (from4, dec4) = bob_restarted.decrypt_incoming(w4)
|
||||
assert_eq(from4, Some(alice_s.public_key))
|
||||
assert_eq(dec4.length(), 2) // DateTime + c4
|
||||
|
||||
// Responder replies with NSR so alice establishes new session
|
||||
let c5 = @ratchet.garlic_clove_block(
|
||||
Local,
|
||||
5U,
|
||||
1700000900U,
|
||||
Data(data=b"nsr2"),
|
||||
)
|
||||
let w5 = bob_restarted.encrypt_to_peer(
|
||||
alice_s.public_key,
|
||||
[c5],
|
||||
1700000407U,
|
||||
rand_b,
|
||||
)
|
||||
let (_, dec5) = alice_mgr.decrypt_incoming(w5)
|
||||
assert_eq(dec5, [c5])
|
||||
|
||||
// Explicit drop_session also forces fresh Bound NS immediately
|
||||
alice_mgr.drop_session(bob_s.public_key)
|
||||
let bob_fresh = @ratchet.RatchetSessionManager::new(bob_s)
|
||||
let c6 = @ratchet.garlic_clove_block(
|
||||
Local,
|
||||
6U,
|
||||
1700000900U,
|
||||
Data(data=b"after-drop"),
|
||||
)
|
||||
let w6 = alice_mgr.encrypt_to_peer(
|
||||
bob_s.public_key,
|
||||
[c6],
|
||||
1700000408U,
|
||||
rand_a,
|
||||
)
|
||||
let (from6, dec6) = bob_fresh.decrypt_incoming(w6)
|
||||
assert_eq(from6, Some(alice_s.public_key))
|
||||
assert_eq(dec6.length(), 2)
|
||||
}
|
||||
Reference in new issue
Block a user