fix: 统一限速单位为 Mbps,与 ppanel-node 节点端对齐
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:
shanshanzhong 2026-03-27 02:46:25 -07:00
parent 315c59e5b7
commit 89e0c03fec

View File

@ -364,12 +364,11 @@ func (l *GetServerUserListLogic) calculateEffectiveSpeedLimit(sub *subscribe.Sub
// 如果已使用流量达到或超过阈值,应用限速
if usedGB >= float64(rule.TrafficUsage) {
// 如果规则限速大于0应用该限速
// rule.SpeedLimit 单位是 KBbaseSpeedLimit 单位是 Bytes需要转换
ruleSpeedBytes := rule.SpeedLimit * 1024
if ruleSpeedBytes > 0 {
// rule.SpeedLimit 单位与 baseSpeedLimit 相同Mbps直接比较
if rule.SpeedLimit > 0 {
// 如果基础限速为0无限速或规则限速更严格使用规则限速
if baseSpeedLimit == 0 || ruleSpeedBytes < baseSpeedLimit {
return ruleSpeedBytes
if baseSpeedLimit == 0 || rule.SpeedLimit < baseSpeedLimit {
return rule.SpeedLimit
}
}
}