mirror of
https://github.com/Sagit-chu/flvx.git
synced 2026-09-29 07:56:37 +08:00
fix(backend): correct speed limit unit conversion from Mbps to Bytes/s
This commit is contained in:
@@ -1045,7 +1045,10 @@ func buildForwardServiceConfigs(baseName string, forward *forwardRecord, tunnel
|
||||
service["metadata"] = map[string]interface{}{"interface": node.InterfaceName}
|
||||
}
|
||||
if limiter != nil && *limiter > 0 {
|
||||
service["limiter"] = strconv.Itoa(*limiter)
|
||||
// Convert Mbps to Bytes/s
|
||||
// 1 Mbps = 1,000,000 bits/s = 125,000 Bytes/s
|
||||
// We use decimal Mbps standard as is common in networking
|
||||
service["limiter"] = strconv.Itoa(*limiter * 125000)
|
||||
}
|
||||
services = append(services, service)
|
||||
}
|
||||
|
||||
@@ -193,6 +193,11 @@ func ParseService(cfg *config.ServiceConfig) (service.Service, error) {
|
||||
xtraffic.LimitsOption(fmt.Sprintf("%s %d %d", xtraffic.ServiceLimitKey, val, val)),
|
||||
)
|
||||
}
|
||||
if lim == nil {
|
||||
lim = xtraffic.NewTrafficLimiter(
|
||||
xtraffic.LimitsOption(fmt.Sprintf("%s %s %s", xtraffic.ServiceLimitKey, cfg.Limiter, cfg.Limiter)),
|
||||
)
|
||||
}
|
||||
}
|
||||
trafficLimiter = listener.TrafficLimiterOption(
|
||||
cache_limiter.NewCachedTrafficLimiter(
|
||||
|
||||
Reference in New Issue
Block a user