fix: traffic_limit 限速值 KB→Bytes 转换,修复与基础限速单位不一致
All checks were successful
Build docker and publish / build (20.15.1) (push) Successful in 7m56s

traffic_limit 的 speed_limit 前端输入单位是 KB,
订阅基础 speed_limit 存储单位是 Bytes,
比较和返回前需要 ×1024 转换为 Bytes,否则限速值异常偏低。

Co-Authored-By: claude-flow <ruv@ruv.net>
This commit is contained in:
shanshanzhong 2026-03-27 02:30:06 -07:00
parent cee97ae630
commit 315c59e5b7

View File

@ -364,10 +364,12 @@ func (l *GetServerUserListLogic) calculateEffectiveSpeedLimit(sub *subscribe.Sub
// 如果已使用流量达到或超过阈值,应用限速
if usedGB >= float64(rule.TrafficUsage) {
// 如果规则限速大于0应用该限速
if rule.SpeedLimit > 0 {
// rule.SpeedLimit 单位是 KBbaseSpeedLimit 单位是 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
}
}
}