MCPcopy
hub / github.com/XTLS/REALITY / NewRatelimitedConn

Function NewRatelimitedConn

tls.go:122–137  ·  view source on GitHub ↗
(conn net.Conn, limit *LimitFallback)

Source from the content-addressed store, hash-verified

120}
121
122func NewRatelimitedConn(conn net.Conn, limit *LimitFallback) net.Conn {
123 if limit.BytesPerSec == 0 {
124 return conn
125 }
126
127 burstBytesPerSec := limit.BurstBytesPerSec
128 if burstBytesPerSec < limit.BytesPerSec {
129 burstBytesPerSec = limit.BytesPerSec
130 }
131
132 return &RatelimitedConn{
133 Conn: conn,
134 After: int64(limit.AfterBytes),
135 Bucket: ratelimit.NewBucketWithRate(float64(limit.BytesPerSec), int64(burstBytesPerSec)),
136 }
137}
138
139var (
140 size = 8192

Callers 1

ServerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…