This commit is contained in:
MHSanaei 2026-04-19 20:56:45 +02:00
parent 83a1bd2194
commit 701aceeda0
No known key found for this signature in database
GPG key ID: 7E4060F2FBE5AB7A
6 changed files with 14 additions and 7 deletions

View file

@ -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;

View file

@ -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();

View file

@ -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

View file

@ -130,6 +130,7 @@
<a-select-option value="body">body</a-select-option>
<a-select-option value="header">header</a-select-option>
<a-select-option value="cookie">cookie</a-select-option>
<a-select-option value="query">query</a-select-option>
</a-select>
</a-form-item>
<a-form-item label="Uplink Data Key"

View file

@ -1331,6 +1331,7 @@
if (!clients || !Array.isArray(clients)) return;
index = this.findIndexOfClient(dbInbound.protocol, clients, client);
if (index < 0 || !clients[index]) return;
clients[index].enable = !clients[index].enable;
clientId = this.getClientId(dbInbound.protocol, clients[index]);
await this.updateClient(clients[index], dbInboundId, clientId);
this.loading(false);
@ -1343,7 +1344,7 @@
},
getInboundClients(dbInbound) {
if (!dbInbound) return null;
const inbound = this.inbounds.find(ib => ib.id === dbInbound.id) || dbInbound.toInbound();
const inbound = dbInbound.toInbound();
return inbound && inbound.clients ? inbound.clients : null;
},
resetClientTraffic(client, dbInboundId, confirmation = true) {

View file

@ -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)