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:
MHSanaei
2026-10-31 09:22:24 +00:00
parent 9cf8c87e8d
commit 87f3f54ea6
7 changed files with 67 additions and 2 deletions
@@ -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)
}
}