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:
@@ -0,0 +1,21 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
ma "github.com/multiformats/go-multiaddr"
|
||||
manet "github.com/multiformats/go-multiaddr/net"
|
||||
)
|
||||
|
||||
// bootstrapRecords turns a node's addresses into the DNS TXT values that make
|
||||
// it a bootstrap node, one per publicly routable address. Loopback and private
|
||||
// addresses are left out: nobody else could use them.
|
||||
func bootstrapRecords(addrs []string) []string {
|
||||
var out []string
|
||||
for _, a := range addrs {
|
||||
m, err := ma.NewMultiaddr(a)
|
||||
if err != nil || !manet.IsPublicAddr(m) {
|
||||
continue
|
||||
}
|
||||
out = append(out, "dnsaddr="+a)
|
||||
}
|
||||
return out
|
||||
}
|
||||
Reference in New Issue
Block a user