From 94b3ce44e69b9957c4192e999a47975ea7616bae Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Thu, 17 Mar 2016 08:18:23 +0100 Subject: [PATCH] connections: The Max{Send,Recv}Kbps variables are supposed to be in KiB/s --- lib/connections/connections.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/connections/connections.go b/lib/connections/connections.go index 2e33fccb..1bcbd278 100644 --- a/lib/connections/connections.go +++ b/lib/connections/connections.go @@ -87,11 +87,13 @@ func NewConnectionService(cfg *config.Wrapper, myID protocol.DeviceID, mdl Model } cfg.Subscribe(service) + // The rate variables are in KiB/s in the UI (despite the camel casing + // of the name). We multiply by 1024 here to get B/s. if service.cfg.Options().MaxSendKbps > 0 { - service.writeRateLimit = ratelimit.NewBucketWithRate(float64(1000*service.cfg.Options().MaxSendKbps), int64(5*1000*service.cfg.Options().MaxSendKbps)) + service.writeRateLimit = ratelimit.NewBucketWithRate(float64(1024*service.cfg.Options().MaxSendKbps), int64(5*1024*service.cfg.Options().MaxSendKbps)) } if service.cfg.Options().MaxRecvKbps > 0 { - service.readRateLimit = ratelimit.NewBucketWithRate(float64(1000*service.cfg.Options().MaxRecvKbps), int64(5*1000*service.cfg.Options().MaxRecvKbps)) + service.readRateLimit = ratelimit.NewBucketWithRate(float64(1024*service.cfg.Options().MaxRecvKbps), int64(5*1024*service.cfg.Options().MaxRecvKbps)) } // There are several moving parts here; one routine per listening address