- 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>
30 lines
1.0 KiB
Go
30 lines
1.0 KiB
Go
package main
|
|
|
|
import (
|
|
"reflect"
|
|
"testing"
|
|
)
|
|
|
|
func TestBootstrapRecordsKeepOnlyPublicAddresses(t *testing.T) {
|
|
const id = "12D3KooWQYhTNQdmr3ArTeUHRYzFg94BKyTkoWBDWez9kSCVe2Xo"
|
|
got := bootstrapRecords([]string{
|
|
"/ip4/127.0.0.1/tcp/4001/p2p/" + id, // loopback
|
|
"/ip4/192.168.1.20/tcp/4001/p2p/" + id, // private
|
|
"/ip4/10.0.0.5/udp/4001/quic-v1/p2p/" + id, // private
|
|
"/ip4/93.184.216.34/tcp/4001/p2p/" + id, // public
|
|
"/ip4/93.184.216.34/udp/4001/quic-v1/p2p/" + id, // public
|
|
"/ip6/::1/tcp/4001/p2p/" + id, // loopback
|
|
"/ip6/2606:4700:4700::1111/tcp/4001/p2p/" + id, // public
|
|
"/ip4/203.0.113.5/tcp/4001/p2p/" + id, // a documentation range, never routable
|
|
"not an address",
|
|
})
|
|
want := []string{
|
|
"dnsaddr=/ip4/93.184.216.34/tcp/4001/p2p/" + id,
|
|
"dnsaddr=/ip4/93.184.216.34/udp/4001/quic-v1/p2p/" + id,
|
|
"dnsaddr=/ip6/2606:4700:4700::1111/tcp/4001/p2p/" + id,
|
|
}
|
|
if !reflect.DeepEqual(got, want) {
|
|
t.Fatalf("got %v\nwant %v", got, want)
|
|
}
|
|
}
|