From 67d8f7a3817d6cbcda55d8f2cf0b28cc9cba9981 Mon Sep 17 00:00:00 2001 From: sagit Date: Mon, 9 Feb 2026 06:13:56 +0000 Subject: [PATCH] fix(backend): correct speed limit unit conversion from Mbps to Bytes/s --- go-backend/internal/http/handler/control_plane.go | 5 ++++- go-gost/x/config/parsing/service/parse.go | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/go-backend/internal/http/handler/control_plane.go b/go-backend/internal/http/handler/control_plane.go index e7f81df..174405a 100644 --- a/go-backend/internal/http/handler/control_plane.go +++ b/go-backend/internal/http/handler/control_plane.go @@ -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) } diff --git a/go-gost/x/config/parsing/service/parse.go b/go-gost/x/config/parsing/service/parse.go index 1c4f684..2e02e29 100644 --- a/go-gost/x/config/parsing/service/parse.go +++ b/go-gost/x/config/parsing/service/parse.go @@ -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(