From 315c59e5b75df961107aecc8827c4283a3a26009 Mon Sep 17 00:00:00 2001 From: shanshanzhong Date: Fri, 27 Mar 2026 02:30:06 -0700 Subject: [PATCH] =?UTF-8?q?fix:=20traffic=5Flimit=20=E9=99=90=E9=80=9F?= =?UTF-8?q?=E5=80=BC=20KB=E2=86=92Bytes=20=E8=BD=AC=E6=8D=A2=EF=BC=8C?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=8E=E5=9F=BA=E7=A1=80=E9=99=90=E9=80=9F?= =?UTF-8?q?=E5=8D=95=E4=BD=8D=E4=B8=8D=E4=B8=80=E8=87=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit traffic_limit 的 speed_limit 前端输入单位是 KB, 订阅基础 speed_limit 存储单位是 Bytes, 比较和返回前需要 ×1024 转换为 Bytes,否则限速值异常偏低。 Co-Authored-By: claude-flow --- internal/logic/server/getServerUserListLogic.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/internal/logic/server/getServerUserListLogic.go b/internal/logic/server/getServerUserListLogic.go index 8a871d0..5c551e0 100644 --- a/internal/logic/server/getServerUserListLogic.go +++ b/internal/logic/server/getServerUserListLogic.go @@ -364,10 +364,12 @@ func (l *GetServerUserListLogic) calculateEffectiveSpeedLimit(sub *subscribe.Sub // 如果已使用流量达到或超过阈值,应用限速 if usedGB >= float64(rule.TrafficUsage) { // 如果规则限速大于0,应用该限速 - if rule.SpeedLimit > 0 { + // rule.SpeedLimit 单位是 KB,baseSpeedLimit 单位是 Bytes,需要转换 + ruleSpeedBytes := rule.SpeedLimit * 1024 + if ruleSpeedBytes > 0 { // 如果基础限速为0(无限速)或规则限速更严格,使用规则限速 - if baseSpeedLimit == 0 || rule.SpeedLimit < baseSpeedLimit { - return rule.SpeedLimit + if baseSpeedLimit == 0 || ruleSpeedBytes < baseSpeedLimit { + return ruleSpeedBytes } } }