From 701aceeda06ec395fcea5c31225869abc103ca14 Mon Sep 17 00:00:00 2001 From: MHSanaei Date: Sun, 19 Apr 2026 20:56:45 +0200 Subject: [PATCH] fix --- web/assets/js/model/dbinbound.js | 5 +++++ web/assets/js/websocket.js | 2 +- web/controller/websocket.go | 6 +++--- web/html/form/stream/stream_xhttp.html | 1 + web/html/inbounds.html | 3 ++- web/websocket/hub.go | 4 ++-- 6 files changed, 14 insertions(+), 7 deletions(-) diff --git a/web/assets/js/model/dbinbound.js b/web/assets/js/model/dbinbound.js index 9132e94e..c347a7eb 100644 --- a/web/assets/js/model/dbinbound.js +++ b/web/assets/js/model/dbinbound.js @@ -90,6 +90,11 @@ class DBInbound { return this.expiryTime < new Date().getTime(); } + invalidateCache() { + this._cachedInbound = null; + this._clientStatsMap = null; + } + toInbound() { if (this._cachedInbound) { return this._cachedInbound; diff --git a/web/assets/js/websocket.js b/web/assets/js/websocket.js index 1009aaf7..ccafef87 100644 --- a/web/assets/js/websocket.js +++ b/web/assets/js/websocket.js @@ -43,7 +43,7 @@ class WebSocketClient { this.ws.onmessage = (event) => { try { // Validate message size (prevent memory issues) - const maxMessageSize = 100 * 1024 * 1024; // 100MB + const maxMessageSize = 10 * 1024 * 1024; // 10MB if (event.data && event.data.length > maxMessageSize) { console.error('WebSocket message too large:', event.data.length, 'bytes'); this.ws.close(); diff --git a/web/controller/websocket.go b/web/controller/websocket.go index 61e6f879..dfb59709 100644 --- a/web/controller/websocket.go +++ b/web/controller/websocket.go @@ -30,9 +30,9 @@ const ( ) var upgrader = ws.Upgrader{ - ReadBufferSize: 32768, // Huge buffers for huge databases - WriteBufferSize: 32768, // Huge buffers to reduce TCP fragmentation - EnableCompression: true, // Automatically GZIP large messages unconditionally + ReadBufferSize: 32768, + WriteBufferSize: 32768, + EnableCompression: true, // Negotiate permessage-deflate compression if the client supports it CheckOrigin: func(r *http.Request) bool { // Check origin for security diff --git a/web/html/form/stream/stream_xhttp.html b/web/html/form/stream/stream_xhttp.html index b43def75..8fe836d0 100644 --- a/web/html/form/stream/stream_xhttp.html +++ b/web/html/form/stream/stream_xhttp.html @@ -130,6 +130,7 @@ body header cookie + query ib.id === dbInbound.id) || dbInbound.toInbound(); + const inbound = dbInbound.toInbound(); return inbound && inbound.clients ? inbound.clients : null; }, resetClientTraffic(client, dbInboundId, confirmation = true) { diff --git a/web/websocket/hub.go b/web/websocket/hub.go index 646ea9e2..1455d1fa 100644 --- a/web/websocket/hub.go +++ b/web/websocket/hub.go @@ -262,7 +262,7 @@ func (h *Hub) Broadcast(messageType MessageType, payload any) { // If message exceeds size limit, send a lightweight invalidate notification // instead of dropping it entirely — the frontend will re-fetch via REST API - const maxMessageSize = 100 * 1024 * 1024 // 100MB (User override) + const maxMessageSize = 10 * 1024 * 1024 // 10MB if len(data) > maxMessageSize { logger.Debugf("WebSocket message too large (%d bytes) for type %s, sending invalidate signal", len(data), messageType) h.broadcastInvalidate(messageType) @@ -307,7 +307,7 @@ func (h *Hub) BroadcastToTopic(messageType MessageType, payload any) { } // If message exceeds size limit, send a lightweight invalidate notification - const maxMessageSize = 100 * 1024 * 1024 // 100MB (User override) + const maxMessageSize = 10 * 1024 * 1024 // 10MB if len(data) > maxMessageSize { logger.Debugf("WebSocket message too large (%d bytes) for type %s, sending invalidate signal", len(data), messageType) h.broadcastInvalidate(messageType)