fix: 统一限速单位为 Mbps,与 ppanel-node 节点端对齐
All checks were successful
Build docker and publish / build (20.15.1) (push) Successful in 8m1s
All checks were successful
Build docker and publish / build (20.15.1) (push) Successful in 8m1s
ppanel-node limiter.go 将 speed_limit 视为 Mbps(× 1000000 / 8 → Bytes/s), 但后端之前存储的是 Bytes(前端 mbToBits 转换),导致节点收到天文数字等于不限速。 - 回滚 traffic_limit KB→Bytes 转换,统一用 Mbps 直接比较 - 部署后需执行数据迁移:UPDATE subscribe SET speed_limit = speed_limit / 1048576 WHERE speed_limit > 0 Co-Authored-By: claude-flow <ruv@ruv.net>
This commit is contained in:
parent
315c59e5b7
commit
89e0c03fec
@ -364,12 +364,11 @@ func (l *GetServerUserListLogic) calculateEffectiveSpeedLimit(sub *subscribe.Sub
|
|||||||
// 如果已使用流量达到或超过阈值,应用限速
|
// 如果已使用流量达到或超过阈值,应用限速
|
||||||
if usedGB >= float64(rule.TrafficUsage) {
|
if usedGB >= float64(rule.TrafficUsage) {
|
||||||
// 如果规则限速大于0,应用该限速
|
// 如果规则限速大于0,应用该限速
|
||||||
// rule.SpeedLimit 单位是 KB,baseSpeedLimit 单位是 Bytes,需要转换
|
// rule.SpeedLimit 单位与 baseSpeedLimit 相同(Mbps),直接比较
|
||||||
ruleSpeedBytes := rule.SpeedLimit * 1024
|
if rule.SpeedLimit > 0 {
|
||||||
if ruleSpeedBytes > 0 {
|
|
||||||
// 如果基础限速为0(无限速)或规则限速更严格,使用规则限速
|
// 如果基础限速为0(无限速)或规则限速更严格,使用规则限速
|
||||||
if baseSpeedLimit == 0 || ruleSpeedBytes < baseSpeedLimit {
|
if baseSpeedLimit == 0 || rule.SpeedLimit < baseSpeedLimit {
|
||||||
return ruleSpeedBytes
|
return rule.SpeedLimit
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user