forked from Mxmilu666/frp
limit: clamp bandwidth limiter burst (#5471)
This commit is contained in:
@@ -34,8 +34,15 @@ func NewWriter(w io.Writer, limiter *rate.Limiter) *Writer {
|
||||
}
|
||||
|
||||
func (w *Writer) Write(p []byte) (n int, err error) {
|
||||
if len(p) == 0 {
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
var nn int
|
||||
b := w.limiter.Burst()
|
||||
if b <= 0 {
|
||||
return 0, invalidBurstError(b)
|
||||
}
|
||||
for {
|
||||
end := len(p)
|
||||
if end == 0 {
|
||||
|
||||
Reference in New Issue
Block a user