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:
+51
-4
@@ -14,9 +14,9 @@ running a node; searching is browser-only through any node's HTTP gateway.
|
||||
`/allmende/1/listings/<region>`. Nodes subscribe to the regions they care
|
||||
about, replicate them, and index them locally. Fine-grained filtering
|
||||
(precision, kind, category, price) happens in local search.
|
||||
- **Discovery**: configured bootstrap peers plus mDNS on the local network;
|
||||
gossipsub peer exchange spreads the mesh. A Kademlia DHT can be added later
|
||||
without protocol changes.
|
||||
- **Discovery**: a DNS-based bootstrap list, remembered peers, a Kademlia DHT per
|
||||
region and mDNS on the local network (see "Finding peers"); NAT traversal
|
||||
through hole punching and relaying bootstrap nodes.
|
||||
- **License**: AGPL-3.0, so modified nodes and gateways must publish their source.
|
||||
- **Launch scope**: one German state or metro area.
|
||||
|
||||
@@ -131,6 +131,48 @@ within 30 days.
|
||||
revocations every 30 minutes, so newcomers hear about them without waiting
|
||||
for a sync.
|
||||
|
||||
## Finding peers
|
||||
|
||||
Four sources, tried together; none is required once a node has met the network.
|
||||
|
||||
1. **Bootstrap.** A fresh node resolves the built-in name
|
||||
`/dnsaddr/allmende.stinnesbeck.com` (`p2p.DefaultBootstrap`): libp2p reads the
|
||||
TXT records of `_dnsaddr.allmende.stinnesbeck.com`, each
|
||||
`dnsaddr=/ip4/<ip>/tcp/4001/p2p/<peer id>` (also `udp/…/quic-v1` and `ip6`).
|
||||
The list of bootstrap nodes therefore changes in DNS, without a new release.
|
||||
`--bootstrap` adds `/p2p/` addresses or other `/dnsaddr/` names;
|
||||
`--no-default-bootstrap` drops the built-in one. A name is resolved at every
|
||||
redial; the last good answer is kept if DNS is briefly unreachable, and a
|
||||
failure is logged once, not every 20 s. A node never dials itself.
|
||||
2. **Remembered peers.** The node saves the peers it is connected to in
|
||||
`peers.json` in its data directory (every 5 minutes and on shutdown: at most
|
||||
100, none older than 30 days, relayed addresses left out) and redials the 10
|
||||
most recent at the next start. After one successful run it no longer needs
|
||||
a bootstrap node.
|
||||
3. **DHT.** A Kademlia DHT with its own protocol prefix (`/allmende/kad/1.0.0`,
|
||||
so it never mixes with the IPFS DHT). For every region it follows, a node
|
||||
advertises itself under `allmende/region/<region>` and looks up the others,
|
||||
connecting to up to 20 until its region topic has 8 peers. Lookups start
|
||||
within seconds and back off to once a minute. Bootstrap nodes only seed the
|
||||
routing table. `--no-dht` turns it off.
|
||||
4. **mDNS** on the local network (`--no-mdns` turns it off).
|
||||
|
||||
**Behind a NAT.** Most nodes run behind a home router. Each node asks the router
|
||||
for a port mapping (UPnP/NAT-PMP), asks other nodes whether it is reachable
|
||||
(AutoNAT), and when it is not, takes a reservation on a bootstrap node (a
|
||||
circuit-relay v2 slot) so others can reach it; the two then try a direct
|
||||
connection by hole punching (DCUtR). Relayed connections are limited by libp2p
|
||||
(2 minutes, 128 KB) and only carry that hand-over. If hole punching fails, a
|
||||
node still takes part: it dials out, and gossip reaches it through the nodes it
|
||||
is connected to.
|
||||
|
||||
**Running a bootstrap node.** `allmende run --public --listen
|
||||
/ip4/0.0.0.0/tcp/4001 --listen /ip4/0.0.0.0/udp/4001/quic-v1` on a machine with
|
||||
a public address (or forwarded ports). `--public` makes it a DHT server and a
|
||||
relay for nodes behind NATs, and it may follow no region at all. It prints the
|
||||
TXT records to publish at `_dnsaddr.<name>`; add one record set per bootstrap
|
||||
node, so several can coexist. Run at least two, on different networks.
|
||||
|
||||
## Messaging
|
||||
|
||||
Implemented in `internal/message` (wire format), `internal/inbox` (owner side)
|
||||
@@ -418,9 +460,13 @@ needed to change the UI (`cd web && npm ci && npm run build`).
|
||||
```
|
||||
allmende init # create identity, show the 12-word phrase (once)
|
||||
allmende run --region u1x [--bootstrap <addr>] # replicate a region, serve the API on 127.0.0.1:8080
|
||||
allmende run --public [--listen …] # a bootstrap node: DHT server and relay
|
||||
allmende recover # restore from the phrase; also yearly cert renewal
|
||||
```
|
||||
|
||||
`run` also takes `--no-default-bootstrap`, `--no-dht` and `--no-mdns`, and keeps
|
||||
the peers it has met in `peers.json` next to its keys.
|
||||
|
||||
## Spam
|
||||
|
||||
Proof-of-work per listing and per revocation, plus subscribable blocklists
|
||||
@@ -430,6 +476,7 @@ Proof-of-work per listing and per revocation, plus subscribable blocklists
|
||||
|
||||
Abuse reporting for messages, reciprocity rules, anti-
|
||||
discrimination (AGG) content rules, blocklists, peer scoring and rate limits,
|
||||
incremental sync and anti-entropy, DHT discovery, image hosting,
|
||||
incremental sync and anti-entropy, a fallback bootstrap list inside the binary
|
||||
for networks that block DNS, image hosting,
|
||||
recovering listings onto a fresh machine with an empty database, a helper to
|
||||
turn a place name into a region.
|
||||
|
||||
Reference in New Issue
Block a user