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

+28 -3
View File
@@ -21,7 +21,7 @@ moon-i2p/
├── sam_client/ # Native POSIX TCP SAMv3 client with PING/PONG, --dest support, and modern I2P defaults
├── router/ # Native MoonBit I2P Router Core with NTCP2 peer pool, floodfill NetDB crawl, Proposal 157 transit tunnels, Garlic/Streaming & SAMv3 bridge
├── cmd/main/ # Pure protocol demo CLI entrypoint
├── cmd/router/ # Native MoonBit I2P router daemon (`--sam`, `--ntcp2-port`, `--peer`, `--peer-dir`, `--su3`, `--reseed`, `--floodfill`)
├── cmd/router/ # Native MoonBit I2P router daemon (`--public`, `--hops`, `--hosts`, `--debug`, `--sam`, `--ntcp2-port`, `--peer`, `--peer-dir`, `--su3`, `--reseed`, `--floodfill`)
├── cmd/client/ # Native SAMv3 CLI (`keygen`, `lookup`, `http-get`, `dial`, `listen`, `--sam`, `--dest`)
└── scripts/ # Loopback SAMv3 bridge (`mock_sam.py`), multi-router `demo.py`, and end-to-end test (`e2e_test.py`)
```
@@ -36,9 +36,34 @@ Every cryptographic primitive in `crypto/` is verified against official standard
- **X25519**: RFC 7748 Sections 5.2 & 6.1
- **Ed25519**: RFC 8032 Section 7.1 test vectors 1–3 (+ non-canonical `S >= L` & tamper rejection)
- **SipHash-2-4**: Official SipHash reference test vector
- **Live I2P Interop**: Verified real `i2pd` `router.info` parsing + Ed25519 signature verification, and full live NTCP2 handshake (Msg 1 → Msg 2 → Msg 3 → Data Phase SipHash length-masked AEAD frames) against a live public I2P floodfill router.
- **Live Public I2P Network Interop**:
- Live `.su3` HTTPS reseed import & Ed25519 verification (`User-Agent: Wget/1.11.4`).
- Live firewalled (`LU`) NTCP2 outbound handshakes and data-phase transport with public I2P routers.
- Live 1-hop & 2-hop Proposal 157 `ShortTunnelBuild` Inbound and Outbound tunnels (including OBEP ECIES `RGarlicKeyAndTag` replies).
- Live tunnel-routed Proposal 154 ECIES `DatabaseLookup` + iterative `DatabaseSearchReply` RI crawl resolving real public eepsite `LeaseSet2`s.
- Live end-to-end `client.exe http-get` over Proposal 144 ECIES Garlic (`NS`/`NSR`/`ES`) + Ed25519 I2P Streaming (including `OFFLINE_SIGNATURE` transient keys) against live public `.b32.i2p` eepsites (`stats.i2p`, `zzz.i2p`, `tracker2.postman.i2p`).
## Running the Native MoonBit Router & SAMv3 Client
## Joining the Public I2P Network
```bash
# Build native router and SAMv3 client
moon build --target native cmd/router
moon build --target native cmd/client
# Join the live public I2P network behind NAT (auto-reseeds, connects NTCP2 peers, builds tunnels)
./_build/native/debug/build/cmd/router/router.exe --public --hops 1 --debug
# Optional flags:
# --hops <1..4> Tunnel length (e.g. --hops 2 for 2-hop Inbound & Outbound tunnels)
# --hosts <hosts.txt> Load hostname=base64dest entries from a local I2P hosts.txt file
# --debug Log peer dials, tunnel builds, NetDB lookups, and Garlic/Streaming state
# Once tunnels are up (`tunnels=in:2/out:2`), resolve and fetch live public eepsites:
./_build/native/debug/build/cmd/client/client.exe lookup kqypgjpjwrphnzebod5ev3ts2vtii6e5tntrg4rnfijqc7rypldq.b32.i2p
./_build/native/debug/build/cmd/client/client.exe http-get kqypgjpjwrphnzebod5ev3ts2vtii6e5tntrg4rnfijqc7rypldq.b32.i2p /
```
## Running the Local MoonBit Router & SAMv3 Client
```bash
# Build the native router and client binaries