mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-11-16 10:05:00 +03:00
fix(node): bound the panel GUIDs a peer reports
A peer's panelGuid is copied into nodes.guid and into every inbound row it reports (an indexed column), a forwarded origin GUID likewise, and a GUID-keyed IP tree or a master's global-traffic push keys one row per client. One oversized value therefore multiplied into gigabytes stored. GUIDs over 64 bytes (panels mint 36-character UUIDs) now fail the heartbeat, fall back to the reporting node's key, or are dropped.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -233,3 +234,17 @@ func TestSnapshotListNotOverlaid_SlimOverlaid(t *testing.T) {
|
||||
t.Errorf("slim list should carry the global overlay, got up=%d", slim[0].ClientStats[0].Up)
|
||||
}
|
||||
}
|
||||
|
||||
// The master GUID keys one stored row per client, so an oversized one is dropped.
|
||||
func TestAcceptGlobalTrafficDropsAnOversizedMasterGuid(t *testing.T) {
|
||||
db := initTrafficTestDB(t)
|
||||
seedClientRow(t, "alice", 1, 0, 0, 0)
|
||||
if err := (&InboundService{}).AcceptGlobalTraffic(strings.Repeat("m", maxPanelGuidLen+1), []*xray.ClientTraffic{{Email: "alice", Up: 1, Down: 1}}); err != nil {
|
||||
t.Fatalf("AcceptGlobalTraffic: %v", err)
|
||||
}
|
||||
var rows int64
|
||||
db.Model(&model.ClientGlobalTraffic{}).Count(&rows)
|
||||
if rows != 0 {
|
||||
t.Fatalf("stored %d row(s) under an oversized master GUID", rows)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user