limits: sync streams, listings per author, inbound connections per IP

A peer may hold 4 sync streams and open 1500 a minute; banned peers get none and cannot redial. A node keeps at most 100 unexpired listings per author (--max-per-author); updates, renewals and deletions of held ones still work. At most 16 inbound connections per public IP or IPv6 /64 (--max-conns-per-ip); local and private addresses are exempt.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AeFqV96dVeBX94inzcgZKw
This commit is contained in:
2026-11-19 00:30:36 +01:00
co-authored by Claude Sonnet 5.5
parent 0b3ead4b23
commit 5ac02360c4
12 changed files with 527 additions and 23 deletions
+19 -14
View File
@@ -67,6 +67,10 @@ func cmdRun(args []string) error {
"identity key (64 hex) of a node operator whose abuse reports count here; repeatable. Your own reports always hide a listing on your node")
hideAfter := fs.Int("hide-after", store.DefaultHideThreshold,
"how many trusted operators must report a listing as a scam before your node hides it (one report of illegal content is enough)")
maxPerAuthor := fs.Int("max-per-author", store.DefaultMaxPerAuthor,
"most unexpired listings this node keeps for one author; more are neither stored nor passed on (-1: no limit)")
maxConnsPerIP := fs.Int("max-conns-per-ip", p2p.DefaultConnsPerIP,
"inbound connections accepted from one public IP address (IPv6: one /64); local and private addresses are exempt (-1: no limit)")
fs.Parse(args)
for _, k := range trustReporters {
if !validKey(k) {
@@ -136,7 +140,7 @@ func cmdRun(args []string) error {
}
st, err := store.Open(filepath.Join(*data, dbFile), store.Options{
Difficulty: *difficulty, MessageDifficulty: *msgDifficulty,
Difficulty: *difficulty, MessageDifficulty: *msgDifficulty, MaxPerAuthor: *maxPerAuthor,
Trust: store.Trust{Self: dev.Cert.Author, Reporters: trustReporters, Threshold: *hideAfter},
})
if err != nil {
@@ -150,19 +154,20 @@ func cmdRun(args []string) error {
defer stop()
node, err := p2p.New(ctx, p2p.Config{
Device: dev,
Store: st,
ListenAddrs: listen,
Bootstrap: bootstrap,
Regions: regions,
MDNS: !*noMDNS,
DHT: !*noDHT,
Public: *public,
MaxConns: *maxConns,
Announce: announceAddrs,
PeerCache: filepath.Join(*data, peersFile),
Difficulty: *difficulty,
Logger: log,
Device: dev,
Store: st,
ListenAddrs: listen,
Bootstrap: bootstrap,
Regions: regions,
MDNS: !*noMDNS,
DHT: !*noDHT,
Public: *public,
MaxConns: *maxConns,
MaxConnsPerIP: *maxConnsPerIP,
Announce: announceAddrs,
PeerCache: filepath.Join(*data, peersFile),
Difficulty: *difficulty,
Logger: log,
MessageDifficulty: *msgDifficulty,
})