From f49dba6f8fb57add5995889cf95f501f34a9baff Mon Sep 17 00:00:00 2001 From: Teddy_Zhu Date: Mon, 1 Apr 2024 15:45:20 +0800 Subject: [PATCH] fix: qos name length over limit (#49) --- pkg/switch/qos.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pkg/switch/qos.go b/pkg/switch/qos.go index 0acabbf..178b9bf 100644 --- a/pkg/switch/qos.go +++ b/pkg/switch/qos.go @@ -7,7 +7,6 @@ import ( cn "github.com/luscis/openlan/pkg/network" "github.com/luscis/openlan/pkg/schema" "strconv" - "strings" "sync" "time" ) @@ -20,13 +19,14 @@ type QosUser struct { Name string Ip string Device string + uniqueName string qosChainIn *cn.FireWallChain out *libol.SubLogger } func (qr *QosUser) RuleName(dir string) string { - nameParts := strings.Split(qr.Name, "@") - return "Qos_" + qr.QosChainName + "-" + dir + "-" + nameParts[0] + + return "Qos_" + qr.QosChainName + "-" + dir + "-" + qr.uniqueName } func (qr *QosUser) InLimitPacket() string { @@ -159,6 +159,7 @@ func (q *QosCtrl) Initialize() { Name: name, InSpeed: limit.InSpeed, Ip: "", + uniqueName: libol.GenString(7), out: libol.NewSubLogger("Qos_" + name), } q.Rules[name] = qr @@ -239,6 +240,7 @@ func (q *QosCtrl) AddOrUpdateQosUser(name string, inSpeed float64) { Name: name, InSpeed: inSpeed, Ip: ip, + uniqueName: libol.GenString(7), out: libol.NewSubLogger("Qos_" + name), } rule.Start(q.chainIn)