Phase 8 networking security - #2
Conversation
…onnection gater, rate limiter - Add ListenAddrs array, NAT traversal, and security config fields - Extend libp2p host with QUIC, RelayService, HolePunching, AutoRelay - Implement ReputationGater (ConnectionGater) with blocklist/allowlist/reputation - Implement PeerRateLimiter (token bucket) for protocol handlers - Wire gater + rate limiters into daemon startup - Update persistMultiaddrs for QUIC addresses - Add 12 new tests (gater, rate limiter, QUIC, NAT, gater integration) - All 30 network tests pass, full suite green Requirements: NETW-02, NETW-04, NETW-06, NETW-07, NETW-08, NETW-09
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (21)
📝 WalkthroughWalkthroughThis pull request implements Phase 8 "Networking Enhancements," introducing QUIC transport, NAT traversal (Circuit Relay v2, hole punching), and security controls (reputation-based connection gating, per-peer rate limiting, peer blocklists/allowlists) through new configuration fields, network components, daemon integration, and comprehensive test coverage. Changes
Sequence Diagram(s)sequenceDiagram
participant App as Application
participant Cfg as Config
participant Daemon as Daemon
participant Host as libp2p Host
participant Gater as ReputationGater
participant RateLim as PeerRateLimiter
participant Handler as Protocol Handler
App->>Cfg: Load config (listen_addrs, enable_hole_punching, etc.)
App->>Daemon: Start(ctx)
Daemon->>Cfg: GetListenAddrs()
Cfg-->>Daemon: []string{TCP, QUIC, ...}
Daemon->>Gater: NewReputationGater(blocked, allowed, threshold)
Daemon->>Host: NewHost(ctx, cfg with Gater + relay opts)
Host->>Host: Apply relay service, hole punching, auto-relay
Host->>Host: Register Gater for dial/secured checks
Host-->>Daemon: *Host{storeLimiter: nil, fetchLimiter: nil}
Daemon->>RateLim: NewPeerRateLimiter(rps, burst)
Daemon->>Host: SetRateLimiters(storeLim, fetchLim)
Host-->>Daemon: (limiters set)
Daemon->>Host: Start listening (persists multiaddrs to cfg.ListenAddrs)
Note over App: Incoming request from peer P
Handler->>RateLim: Allow(P)
alt Rate limit exceeded
RateLim-->>Handler: false
Handler->>Handler: Send error response ("rate limited")
else Within limit
RateLim-->>Handler: true
Handler->>Handler: Process request normally
end
Note over App: Peer connects
Gater->>Gater: isAllowed(peer_id)
alt Peer blocked
Gater-->>Host: false (reject)
else Peer in allowlist/above threshold
Gater-->>Host: true (allow)
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary by CodeRabbit
Release Notes
New Features