fix(fed): sanitize peer rows, cap peer bytes, add --peer-blocklist
CI / Docker image (build and smoke test) (push) Skipped
CI / Format and vet (push) Successful in 24s
CI / Tests (Linux, race detector) (push) Successful in 34s
CI / Dependency audit (push) Successful in 14s
Release / Plan (reuse the published image?) (push) Successful in 3s
Release / ci (push) Skipped
Release / Build image (amd64) (push) Skipped
Release / Build image (arm64) (push) Skipped
Release / Publish tags (push) Successful in 13s
Release / Gitea release (push) Successful in 4s
CI / Docker image (build and smoke test) (push) Skipped
CI / Format and vet (push) Successful in 24s
CI / Tests (Linux, race detector) (push) Successful in 34s
CI / Dependency audit (push) Successful in 14s
Release / Plan (reuse the published image?) (push) Successful in 3s
Release / ci (push) Skipped
Release / Build image (amd64) (push) Skipped
Release / Build image (arm64) (push) Skipped
Release / Publish tags (push) Successful in 13s
Release / Gitea release (push) Successful in 4s
Peer events and summary rows are rebuilt from validated fields (address, country code, category) and the forged/unban flags from peers are ignored. The live relay drops a peer that exceeds about 1 MB/s, also within a single window. --peer-blocklist=off keeps the hub's blocklist to local observations. UI polish: plural forms, blocklist preview and downloads follow the active slice, compact IP cards on phones. Docs for the 1.1.0 interface. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f4b295f582
commit
783b0cba3e
31 files changed
+355
-127
No files matched your search
@@ -56,7 +56,7 @@ func TestLiveRelaySanitizesAndDrops(t *testing.T) {
|
||||
ch, stop := h.Subscribe()
|
||||
defer stop()
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
defer func() { cancel(); h.WaitStream() }()
|
||||
h.Stream(ctx)
|
||||
|
||||
var got []store.LiveEvent
|
||||
@@ -110,7 +110,7 @@ func TestLiveRateLimitAndFlag(t *testing.T) {
|
||||
p, _ := fed.ParsePeer("edge=" + srv.URL)
|
||||
h := fed.NewHub([]fed.Peer{p}, "tok")
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
defer func() { cancel(); h.WaitStream() }()
|
||||
h.Stream(ctx)
|
||||
deadline := time.Now().Add(5 * time.Second)
|
||||
for len(h.Recent(500)) == 0 && time.Now().Before(deadline) {
|
||||
@@ -133,7 +133,7 @@ func TestLiveWithRealPeerServer(t *testing.T) {
|
||||
p, _ := fed.ParsePeer("edge=" + srv.URL)
|
||||
h := fed.NewHub([]fed.Peer{p}, "peer-secret-0123456789-abcdefghijklmnopqr")
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
defer func() { cancel(); h.WaitStream() }()
|
||||
h.Refresh(ctx)
|
||||
h.Stream(ctx)
|
||||
deadline := time.Now().Add(5 * time.Second)
|
||||
@@ -153,3 +153,28 @@ func TestLiveWithRealPeerServer(t *testing.T) {
|
||||
t.Fatalf("hosts %+v", hs)
|
||||
}
|
||||
}
|
||||
|
||||
func TestLiveByteFloodDropsConnection(t *testing.T) {
|
||||
defer fed.SetLiveLimits(200*time.Millisecond, 10_000, 100*time.Millisecond)()
|
||||
start := time.Now()
|
||||
var conns atomic.Int32
|
||||
pad := strings.Repeat("a", 1000)
|
||||
srv := fakeStream(t, &conns, func(w http.ResponseWriter) {
|
||||
for i := 0; i < 200; i++ { // ~200 KB at once: far above 10 KB/s
|
||||
fmt.Fprintf(w, ": %s\n", pad)
|
||||
}
|
||||
})
|
||||
defer srv.Close()
|
||||
p, _ := fed.ParsePeer("edge=" + srv.URL)
|
||||
h := fed.NewHub([]fed.Peer{p}, "tok")
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer func() { cancel(); h.WaitStream() }()
|
||||
h.Stream(ctx)
|
||||
// the flood ends the connection (window check), then the hub reconnects after the backoff
|
||||
for conns.Load() < 2 {
|
||||
if time.Since(start) > 2500*time.Millisecond {
|
||||
t.Fatalf("no drop and reconnection (%d connections)", conns.Load())
|
||||
}
|
||||
time.Sleep(20 * time.Millisecond)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user