feat: add public I2P network mode to router daemon
check / check (ubuntu-latest) (push) Failing after 26s
check / check (macos-latest) (push) Failing after 28s
check / check (windows-latest) (push) Failing after 29s

- Add `--public`, `--hops`, `--hosts`, and `--debug` router flags; `--public` auto-reseeds from the live network and keeps a status loop running.
- Route NetDB lookups through tunnels with Noise_N garlic wrapping, fan out to two floodfills, and fetch unknown RouterInfos in the background.
- Back off failed NTCP2 peers and fall back to IPv6 addresses when no IPv4 NTCP2 address is available.
- Size session LeaseSet2 expiry from lease end dates and use the destination's X25519 key when present.
- Add canonical Ed25519 Destination KeyCertificate constructors with round-trip tests.
- Fix DatabaseStore gzip handling to honor the length prefix, and send `Wget/1.11.4` as the reseed User-Agent.
This commit is contained in:
nandi committed 2026-11-28 00:11:28 -08:00
1 parent ae72b00323
commit 54cfb2faa9
25 files changed
+2033 -191

No files matched your search

+23 -14
View File
@@ -146,7 +146,7 @@ pub fn ShortBuildRequestRecord::decode_154(
///|
/// Canonical Proposal 157 chained HKDF key derivation:
/// `SMTunnelReplyKey` -> `SMTunnelLayerKey` -> `TunnelLayerIVKey` (-> `RGarlicKeyAndTag` for OBEP).
/// `SMTunnelReplyKey` -> `SMTunnelLayerKey` (-> `TunnelLayerIVKey` -> `RGarlicKeyAndTag` for OBEP).
fn derive_hop_keys(
ck : Bytes,
h : Bytes,
@@ -164,21 +164,30 @@ fn derive_hop_keys(
let ck2 = t_slice(kd2, 0, 32)
let layer_key = t_slice(kd2, 32, 32)
let kd3 = @crypto.hkdf(ck2, b"", b"TunnelLayerIVKey", 64) catch {
e => raise Crypto(e)
}
let ck3 = t_slice(kd3, 0, 32)
let iv_key = t_slice(kd3, 32, 32)
let (garlic_key, garlic_tag) = if is_obep {
if is_obep {
let kd3 = @crypto.hkdf(ck2, b"", b"TunnelLayerIVKey", 64) catch {
e => raise Crypto(e)
}
let ck3 = t_slice(kd3, 0, 32)
let iv_key = t_slice(kd3, 32, 32)
let kd4 = @crypto.hkdf(ck3, b"", b"RGarlicKeyAndTag", 64) catch {
e => raise Crypto(e)
}
(Some(t_slice(kd4, 0, 32)), Some(t_slice(kd4, 32, 8)))
// Canonical i2pd: garlic_tag = kd4[0..8], garlic_key = kd4[32..64]
let garlic_tag = Some(t_slice(kd4, 0, 8))
let garlic_key = Some(t_slice(kd4, 32, 32))
{ reply_key, layer_key, iv_key, handshake_hash: h, garlic_key, garlic_tag, }
} else {
(None, None)
// Non-OBEP hops use ck2 directly as iv_key (no TunnelLayerIVKey HKDF step)
{
reply_key,
layer_key,
iv_key: ck2,
handshake_hash: h,
garlic_key: None,
garlic_tag: None,
}
}
{ reply_key, layer_key, iv_key, handshake_hash: h, garlic_key, garlic_tag, }
}
///|
@@ -366,7 +375,7 @@ pub fn build_short_tunnel_request(
let keys_k = hop_keys[k].1
rec = @crypto.chacha20_xor(
keys_k.reply_key,
0U,
1U,
make_slot_nonce(slot_m),
rec,
) catch {
@@ -430,7 +439,7 @@ pub fn process_short_tunnel_build_hop(
)
} else {
out.push(
@crypto.chacha20_xor(keys.reply_key, 0U, make_slot_nonce(j), records[j]) catch {
@crypto.chacha20_xor(keys.reply_key, 1U, make_slot_nonce(j), records[j]) catch {
e => raise Crypto(e)
},
)
@@ -457,7 +466,7 @@ pub fn decrypt_short_tunnel_replies(
let keys_k = hop_slots_and_keys[k].1
rec = @crypto.chacha20_xor(
keys_k.reply_key,
0U,
1U,
make_slot_nonce(slot_m),
rec,
) catch {