Add bootstrap nodes, DNS-based discovery, a DHT per region and NAT traversal

- Bootstrap: built-in /dnsaddr/allmende.stinnesbeck.com (TXT records at
  _dnsaddr.<name>), resolved at every redial with the last good answer kept;
  --bootstrap takes /p2p/ or /dnsaddr/ entries, --no-default-bootstrap drops
  the built-in one. Stopping never waits for a stuck resolver.
- Remembered peers in peers.json (saved every 5 min and on shutdown, redialled
  at the next start)
- Private Kademlia DHT (/allmende prefix), advertised and looked up per region
  with quick first attempts and a backoff; --no-dht turns it off
- NAT traversal: port mapping, hole punching, AutoRelay through bootstrap nodes
- --public: DHT server and relay for a bootstrap node; prints the TXT records
- Docker, NixOS module (public, defaultBootstrap, QUIC/UDP) and docs updated
- e2e: bootstrap node scenario, seed cache restart, and polling that really polls

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-17 22:14:34 +01:00
co-authored by Claude Sonnet 5.5
parent a81595e9ee
commit e7bec4fb63
18 changed files with 1281 additions and 69 deletions
+4 -2
View File
@@ -46,8 +46,10 @@ pkgs.testers.runNixOSTest {
machine.succeed("ss -ltn | grep -q '127.0.0.1:8080'")
machine.fail("ss -ltn | grep -q '0.0.0.0:8080'")
with subtest("it survives a restart"):
machine.succeed("systemctl restart allmende")
with subtest("it stops promptly even though the VM has no DNS, and restarts"):
# The built-in bootstrap name cannot be resolved here; stopping must not wait for it.
machine.succeed("timeout 3 systemctl stop allmende")
machine.succeed("systemctl start allmende")
machine.wait_for_open_port(8080)
'';
}