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
+8 -5
View File
@@ -4,11 +4,12 @@
# docker build -t allmende .
# docker run --rm -it -v allmende-data:/data allmende init # once; shows the recovery phrase
# docker run -d --name allmende -v allmende-data:/data \
# -p 127.0.0.1:8080:8080 -p 4001:4001 allmende # run (Bonn by default)
# -p 127.0.0.1:8080:8080 -p 4001:4001 -p 4001:4001/udp allmende # run (Bonn by default)
#
# The HTTP port also serves the owner API, which the admin token protects, so
# publish it on 127.0.0.1 only and put a TLS proxy in front for public use.
# Port 4001 is the libp2p port other nodes connect to.
# Port 4001 (TCP and UDP/QUIC) is the libp2p port other nodes connect to.
# The node remembers its peers in /data/peers.json, so keep the volume.
ARG GO_VERSION=1.27
@@ -25,11 +26,13 @@ COPY --from=build /out/allmende /usr/local/bin/allmende
USER allmende
ENV ALLMENDE_DATA=/data
VOLUME /data
EXPOSE 8080 4001
EXPOSE 8080 4001/tcp 4001/udp
HEALTHCHECK --interval=30s --timeout=5s --start-period=20s \
CMD wget -qO- http://127.0.0.1:8080/api/v1/status >/dev/null || exit 1
ENTRYPOINT ["allmende"]
# Override the whole command to change regions or add peers, e.g.
# docker run ... allmende run --http 0.0.0.0:8080 --listen /ip4/0.0.0.0/tcp/4001 \
# docker run ... allmende run --http 0.0.0.0:8080 \
# --listen /ip4/0.0.0.0/tcp/4001 --listen /ip4/0.0.0.0/udp/4001/quic-v1 \
# --region u1j --region u1h --bootstrap /ip4/203.0.113.5/tcp/4001/p2p/<peer id>
CMD ["run", "--http", "0.0.0.0:8080", "--listen", "/ip4/0.0.0.0/tcp/4001", "--region", "u1j"]
# A bootstrap node adds --public (and needs a public address).
CMD ["run", "--http", "0.0.0.0:8080", "--listen", "/ip4/0.0.0.0/tcp/4001", "--listen", "/ip4/0.0.0.0/udp/4001/quic-v1", "--region", "u1j"]