saucelabs / forwarder

Forwarder is a production-ready, fast MITM proxy with PAC support. It's suitable for debugging, intercepting and manipulating HTTP traffic. It's used as a core component of Sauce Labs Sauce Connect Proxy.
https://forwarder-proxy.io
Mozilla Public License 2.0
221 stars 13 forks source link

ratelimit: make it a global limit and invert #655

Closed Choraden closed 5 months ago

Choraden commented 8 months ago

Currently the limits have confusing logic:

if rl, wl := l.ReadLimit, l.WriteLimit; rl > 0 || wl > 0 {
    // Notice that the ReadLimit stands for the read limit *from* a proxy, and the WriteLimit
    // stands for the write limit *to* a proxy, thus the ReadLimit is in fact
    // a txBandwidth and the WriteLimit is a rxBandwidth.
    ll = ratelimit.NewListener(ll, wl, rl)
}

Invert that and share the limit across all connections.