mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-06-06 21:24:10 +00:00
fix
This commit is contained in:
parent
83a1bd2194
commit
701aceeda0
6 changed files with 14 additions and 7 deletions
|
|
@ -90,6 +90,11 @@ class DBInbound {
|
||||||
return this.expiryTime < new Date().getTime();
|
return this.expiryTime < new Date().getTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
invalidateCache() {
|
||||||
|
this._cachedInbound = null;
|
||||||
|
this._clientStatsMap = null;
|
||||||
|
}
|
||||||
|
|
||||||
toInbound() {
|
toInbound() {
|
||||||
if (this._cachedInbound) {
|
if (this._cachedInbound) {
|
||||||
return this._cachedInbound;
|
return this._cachedInbound;
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ class WebSocketClient {
|
||||||
this.ws.onmessage = (event) => {
|
this.ws.onmessage = (event) => {
|
||||||
try {
|
try {
|
||||||
// Validate message size (prevent memory issues)
|
// 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) {
|
if (event.data && event.data.length > maxMessageSize) {
|
||||||
console.error('WebSocket message too large:', event.data.length, 'bytes');
|
console.error('WebSocket message too large:', event.data.length, 'bytes');
|
||||||
this.ws.close();
|
this.ws.close();
|
||||||
|
|
|
||||||
|
|
@ -30,9 +30,9 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
var upgrader = ws.Upgrader{
|
var upgrader = ws.Upgrader{
|
||||||
ReadBufferSize: 32768, // Huge buffers for huge databases
|
ReadBufferSize: 32768,
|
||||||
WriteBufferSize: 32768, // Huge buffers to reduce TCP fragmentation
|
WriteBufferSize: 32768,
|
||||||
EnableCompression: true, // Automatically GZIP large messages unconditionally
|
EnableCompression: true, // Negotiate permessage-deflate compression if the client supports it
|
||||||
|
|
||||||
CheckOrigin: func(r *http.Request) bool {
|
CheckOrigin: func(r *http.Request) bool {
|
||||||
// Check origin for security
|
// Check origin for security
|
||||||
|
|
|
||||||
|
|
@ -130,6 +130,7 @@
|
||||||
<a-select-option value="body">body</a-select-option>
|
<a-select-option value="body">body</a-select-option>
|
||||||
<a-select-option value="header">header</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="cookie">cookie</a-select-option>
|
||||||
|
<a-select-option value="query">query</a-select-option>
|
||||||
</a-select>
|
</a-select>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item label="Uplink Data Key"
|
<a-form-item label="Uplink Data Key"
|
||||||
|
|
|
||||||
|
|
@ -1331,6 +1331,7 @@
|
||||||
if (!clients || !Array.isArray(clients)) return;
|
if (!clients || !Array.isArray(clients)) return;
|
||||||
index = this.findIndexOfClient(dbInbound.protocol, clients, client);
|
index = this.findIndexOfClient(dbInbound.protocol, clients, client);
|
||||||
if (index < 0 || !clients[index]) return;
|
if (index < 0 || !clients[index]) return;
|
||||||
|
clients[index].enable = !clients[index].enable;
|
||||||
clientId = this.getClientId(dbInbound.protocol, clients[index]);
|
clientId = this.getClientId(dbInbound.protocol, clients[index]);
|
||||||
await this.updateClient(clients[index], dbInboundId, clientId);
|
await this.updateClient(clients[index], dbInboundId, clientId);
|
||||||
this.loading(false);
|
this.loading(false);
|
||||||
|
|
@ -1343,7 +1344,7 @@
|
||||||
},
|
},
|
||||||
getInboundClients(dbInbound) {
|
getInboundClients(dbInbound) {
|
||||||
if (!dbInbound) return null;
|
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;
|
return inbound && inbound.clients ? inbound.clients : null;
|
||||||
},
|
},
|
||||||
resetClientTraffic(client, dbInboundId, confirmation = true) {
|
resetClientTraffic(client, dbInboundId, confirmation = true) {
|
||||||
|
|
|
||||||
|
|
@ -262,7 +262,7 @@ func (h *Hub) Broadcast(messageType MessageType, payload any) {
|
||||||
|
|
||||||
// If message exceeds size limit, send a lightweight invalidate notification
|
// If message exceeds size limit, send a lightweight invalidate notification
|
||||||
// instead of dropping it entirely — the frontend will re-fetch via REST API
|
// 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 {
|
if len(data) > maxMessageSize {
|
||||||
logger.Debugf("WebSocket message too large (%d bytes) for type %s, sending invalidate signal", len(data), messageType)
|
logger.Debugf("WebSocket message too large (%d bytes) for type %s, sending invalidate signal", len(data), messageType)
|
||||||
h.broadcastInvalidate(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
|
// 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 {
|
if len(data) > maxMessageSize {
|
||||||
logger.Debugf("WebSocket message too large (%d bytes) for type %s, sending invalidate signal", len(data), messageType)
|
logger.Debugf("WebSocket message too large (%d bytes) for type %s, sending invalidate signal", len(data), messageType)
|
||||||
h.broadcastInvalidate(messageType)
|
h.broadcastInvalidate(messageType)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue