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

http proxy: isLocalhost check allocates lots of memory #628

Closed mmatczuk closed 6 months ago

mmatczuk commented 8 months ago

The localhost check uses nopResolver()

https://github.com/saucelabs/forwarder/blob/2c0cba14a2f375ca4430092c68ecc5be1234e47c/http_proxy.go#L507

Using it proves to allocate large amounts of memory. Causing a heap memory hiccup visible in the metrics.

Screenshot 2024-01-02 at 15 15 54

We should change the implementation. I suggest we read and watch /etc/hosts file instead.