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

+22
View File
@@ -45,6 +45,28 @@ test "Destination X25519+Ed25519 key extraction, Base64, and .b32.i2p address" {
assert_true(b32.has_suffix(".b32.i2p"))
}
///|
test "Destination Ed25519 canonical KeyCertificate (sig=7, crypto=0) round-trip" {
let sig_pub = Bytes::make(32, b'\x37')
let pad = Bytes::make(352, b'\x9a')
let dest = @common.Destination::new_ed25519(sig_pub, padding=pad)
let raw = dest.to_bytes()
assert_eq(raw.length(), 391)
// Trailing KeyCertificate: 05 (Key) | 00 04 (len=4) | 00 07 (Ed25519) | 00 00 (ElGamal)
assert_eq(raw[384], b'\x05')
assert_eq(raw[385], b'\x00')
assert_eq(raw[386], b'\x04')
assert_eq(raw[387], b'\x00')
assert_eq(raw[388], b'\x07')
assert_eq(raw[389], b'\x00')
assert_eq(raw[390], b'\x00')
assert_eq(dest.inner.crypto_type(), ElGamal)
assert_eq(dest.inner.signing_type(), EdDsaSha512Ed25519)
assert_eq(dest.inner.signing_public_key(), sig_pub)
let decoded = @common.Destination::decode(@encoding.Reader::new(raw))
assert_eq(decoded, dest)
}
///|
test "RouterInfo encode and decode round-trip" {
let ri_id = @common.RouterIdentity::new_x25519_ed25519(
+35
View File
@@ -9,6 +9,33 @@ pub struct KeysAndCert {
certificate : Certificate
}
///|
/// Constructs a modern Ed25519 `Destination` `KeysAndCert` (CryptoType=0 ElGamal, SigType=7 Ed25519).
/// Per I2P Proposal 123/144, Destinations always use ElGamal (0) in their KeyCertificate while
/// placing active X25519 encryption keys in `LeaseSet2.encryption_keys`:
/// `padding` (352 bytes, or zero-filled if omitted) occupies bytes 0..352,
/// and the Ed25519 signing public key (32 bytes) is right-aligned at bytes 352..384.
pub fn KeysAndCert::new_destination_ed25519(
signing_pub : Bytes,
padding~ : Bytes = b"",
) -> KeysAndCert raise CommonError {
if signing_pub.length() != 32 {
raise InvalidLength(
"Ed25519 public key must be 32 bytes, got \{signing_pub.length()}",
)
}
let buf = FixedArray::make(384, b'\x00')
let pad_len = if padding.length() < 352 { padding.length() } else { 352 }
for i = 0; i < pad_len; i = i + 1 {
buf[i] = padding[i]
}
for i = 0; i < 32; i = i + 1 {
buf[352 + i] = signing_pub[i]
}
let cert = Certificate::Key(KeyCertificate::new(EdDsaSha512Ed25519, ElGamal))
{ key_data: Bytes::from_array(buf), certificate: cert, }
}
///|
/// Constructs a modern X25519 + Ed25519 `KeysAndCert` (CryptoType=4, SigType=7).
/// Per I2P spec: X25519 public key (32 bytes) is placed at bytes 0..32,
@@ -138,6 +165,14 @@ pub fn Destination::new(inner : KeysAndCert) -> Destination {
{ inner, }
}
///|
pub fn Destination::new_ed25519(
signing_pub : Bytes,
padding~ : Bytes = b"",
) -> Destination raise CommonError {
{ inner: KeysAndCert::new_destination_ed25519(signing_pub, padding~), }
}
///|
pub fn Destination::new_x25519_ed25519(
crypto_pub : Bytes,
+2
View File
@@ -56,6 +56,7 @@ pub fn Destination::encode(Self, @encoding.Writer) -> Unit
pub fn Destination::from_base64(String) -> Self raise CommonError
pub fn Destination::hash(Self) -> Hash
pub fn Destination::new(KeysAndCert) -> Self
pub fn Destination::new_ed25519(Bytes, padding? : Bytes) -> Self raise CommonError
pub fn Destination::new_x25519_ed25519(Bytes, Bytes, padding? : Bytes) -> Self raise CommonError
pub fn Destination::to_base64(Self) -> String
pub fn Destination::to_bytes(Self) -> Bytes
@@ -93,6 +94,7 @@ pub fn KeysAndCert::crypto_type(Self) -> CryptoPublicKeyType
pub fn KeysAndCert::decode(@encoding.Reader) -> Self raise CommonError
pub fn KeysAndCert::encode(Self, @encoding.Writer) -> Unit
pub fn KeysAndCert::hash(Self) -> Hash
pub fn KeysAndCert::new_destination_ed25519(Bytes, padding? : Bytes) -> Self raise CommonError
pub fn KeysAndCert::new_x25519_ed25519(Bytes, Bytes, padding? : Bytes) -> Self raise CommonError
pub fn KeysAndCert::signing_public_key(Self) -> Bytes
pub fn KeysAndCert::signing_type(Self) -> SigningPublicKeyType