From a0e52faa4424be7b923b483c78760e70ab1a622b Mon Sep 17 00:00:00 2001 From: Jaakko Vanhala Date: Thu, 9 Apr 2026 23:14:06 +0300 Subject: [PATCH] Localhost vapautettu IP-yhteysrajasta, tuotannon raja nostettu 20:een MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Kehitysympäristössä (127.0.0.1) ei enää yhteysrajaa — useita selainikkunoita ja native-nodeja voi yhdistää vapaasti. Tuotannossa raja 10→20 per ulkoinen IP. Co-Authored-By: Claude Opus 4.6 (1M context) --- network-poc/hub/src/main.rs | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/network-poc/hub/src/main.rs b/network-poc/hub/src/main.rs index ed0a6e8..eacf07b 100644 --- a/network-poc/hub/src/main.rs +++ b/network-poc/hub/src/main.rs @@ -518,16 +518,19 @@ async fn ws_handler( .and_then(|s| s.trim().parse::().ok()) .unwrap_or_else(|| addr.ip()); - // Max yhteyttä per IP: jokainen selain tarvitsee 2 (UI + coder-node) + // Max yhteyttä per IP (ei rajoiteta localhost/127.0.0.1) { - let conns = state.ip_connections.lock().unwrap(); - let count = conns.get(&ip).copied().unwrap_or(0); - if count >= 10 { - tracing::warn!("IP {} ylitti yhteysrajan ({}/10) — estetty", ip, count); - return ( - axum::http::StatusCode::TOO_MANY_REQUESTS, - "Max 10 yhteyttä per IP", - ).into_response(); + let is_local = ip.is_loopback(); + if !is_local { + let conns = state.ip_connections.lock().unwrap(); + let count = conns.get(&ip).copied().unwrap_or(0); + if count >= 20 { + tracing::warn!("IP {} ylitti yhteysrajan ({}/20) — estetty", ip, count); + return ( + axum::http::StatusCode::TOO_MANY_REQUESTS, + "Max 20 yhteyttä per IP", + ).into_response(); + } } }