fix: harden ratchet sessions and throttle BitTorrent DHT traffic
check / check (macos-latest) (push) Failing after 26s
check / check (ubuntu-latest) (push) Failing after 27s
check / check (windows-latest) (push) Failing after 26s

- Ratchet: cap outbound NSR pending entries per peer and globally, age them out after 180s, and prune expired or excess sessions.
- Ratchet: keep NSR pending entries across multi-NSR replies, skip failed decrypts instead of aborting, and bound inbound pending entries.
- Ratchet: expire sessions with stale receive state or high message counts; only mark sessions confirmed when no reply has been received.
- Torrent DHT: add per-node cooldowns for get_peers and announce, limit fanout and pending transactions, and skip nodes already in the routing table.
- Torrent DHT: use slower maintenance and query intervals in public mode.
- Torrent peers: mark ratchet sessions stale after stalled SYN, connect timeout, handshake timeout, or idle timeout so they re-key.
- Torrent peers: raise the per-torrent peer limit to 16 and log I2CP decode errors in debug mode.
This commit is contained in:
nandi committed 2026-11-28 19:43:10 -08:00
1 parent 4bb81f1b80
commit 5d97ad8b28
4 files changed
+474 -71

No files matched your search

+21 -1
View File
@@ -468,6 +468,19 @@ fn Router::finish_remote_stream_connect(
)
}
///|
fn streaming_err_msg(e : @streaming.StreamingError) -> String {
match e {
Encoding(_) => "encoding error"
Common(_) => "common decode error"
Crypto(_) => "crypto error"
InvalidFormat(msg) => "invalid format: \{msg}"
InvalidLength(msg) => "invalid length: \{msg}"
InvalidSignature => "invalid signature"
ProtocolError(msg) => "protocol error: \{msg}"
}
}
///|
fn Router::handle_incoming_garlic(
self : Router,
@@ -526,7 +539,14 @@ fn Router::handle_incoming_garlic(
Some(mgr) => {
let prev_streams = mgr.streams.length()
let conn_opt = mgr.handle_incoming_i2cp(data, now_ms) catch {
_ => None
e => {
if self.debug {
println(
"[debug] incoming I2CP error on \{sess.id}: \{streaming_err_msg(e)}",
)
}
None
}
}
let send_ls2_now = mgr.streams.length() > prev_streams
match conn_opt {