From d7bec4a74f2d375c9c8197793f2b1046e9a228bc Mon Sep 17 00:00:00 2001 From: Meo597 <197331664+Meo597@users.noreply.github.com> Date: Sun, 8 Jun 2025 18:10:49 +0800 Subject: [PATCH] int64 --- common.go | 2 +- tls.go | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/common.go b/common.go index d76d38e..8cd7f91 100644 --- a/common.go +++ b/common.go @@ -539,7 +539,7 @@ const ( type LimitFallback struct { AfterBytes int64 - BytesPerSec float64 + BytesPerSec int64 BurstBytesPerSec int64 } diff --git a/tls.go b/tls.go index 0603a2b..bbe0ec4 100644 --- a/tls.go +++ b/tls.go @@ -43,7 +43,6 @@ import ( "errors" "fmt" "io" - "math" "net" "os" "runtime" @@ -120,11 +119,11 @@ func (c *RatelimitedConn) Write(b []byte) (int, error) { return n, err } -func NewBucketWithRate(bytesPerSec float64, burstBytesPerSec int64) *ratelimit.Bucket { - if burstBytesPerSec < int64(math.Ceil(bytesPerSec)) { - burstBytesPerSec = int64(math.Ceil(bytesPerSec)) +func NewBucketWithRate(bytesPerSec int64, burstBytesPerSec int64) *ratelimit.Bucket { + if burstBytesPerSec < bytesPerSec { + burstBytesPerSec = bytesPerSec } - return ratelimit.NewBucketWithRate(bytesPerSec, burstBytesPerSec) + return ratelimit.NewBucketWithRate(float64(bytesPerSec), burstBytesPerSec) } var (