Skip to content

Commit

Permalink
lib/connections: Don't info log about LAN if there are no rate limits (
Browse files Browse the repository at this point in the history
  • Loading branch information
imsodin authored and calmh committed Oct 5, 2018
1 parent 714a47f commit c9d6366
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions lib/connections/limiter.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,36 +134,38 @@ func (lim *limiter) CommitConfiguration(from, to config.Configuration) bool {
return true
}

limited := false
sendLimitStr := "is unlimited"
recvLimitStr := "is unlimited"

// The rate variables are in KiB/s in the config (despite the camel casing
// of the name). We multiply by 1024 to get bytes/s.
if to.Options.MaxRecvKbps <= 0 {
lim.read.SetLimit(rate.Inf)
} else {
lim.read.SetLimit(1024 * rate.Limit(to.Options.MaxRecvKbps))
recvLimitStr = fmt.Sprintf("limit is %d KiB/s", to.Options.MaxRecvKbps)
limited = true
}

if to.Options.MaxSendKbps <= 0 {
lim.write.SetLimit(rate.Inf)
} else {
lim.write.SetLimit(1024 * rate.Limit(to.Options.MaxSendKbps))
sendLimitStr = fmt.Sprintf("limit is %d KiB/s", to.Options.MaxSendKbps)
limited = true
}

lim.limitsLAN.set(to.Options.LimitBandwidthInLan)

sendLimitStr := "is unlimited"
recvLimitStr := "is unlimited"
if to.Options.MaxSendKbps > 0 {
sendLimitStr = fmt.Sprintf("limit is %d KiB/s", to.Options.MaxSendKbps)
}
if to.Options.MaxRecvKbps > 0 {
recvLimitStr = fmt.Sprintf("limit is %d KiB/s", to.Options.MaxRecvKbps)
}
l.Infof("Overall send rate %s, receive rate %s", sendLimitStr, recvLimitStr)

if to.Options.LimitBandwidthInLan {
l.Infoln("Rate limits apply to LAN connections")
} else {
l.Infoln("Rate limits do not apply to LAN connections")
if limited {
if to.Options.LimitBandwidthInLan {
l.Infoln("Rate limits apply to LAN connections")
} else {
l.Infoln("Rate limits do not apply to LAN connections")
}
}

return true
Expand Down

0 comments on commit c9d6366

Please sign in to comment.