tinyproxy / tinyproxy

tinyproxy - a light-weight HTTP/HTTPS proxy daemon for POSIX operating systems
GNU General Public License v2.0
4.88k stars 668 forks source link

tinyproxy sends empty response instead of error code when host not found via socks upstream #433

Open vituperative opened 2 years ago

vituperative commented 2 years ago

Version: git master

Steps to reproduce:

curl via Tor: curl -i -x socks5h://localhost:9050 http://***deadononionsite***.onion/ curl: (97) Can't complete SOCKS5 connection to deadonnionsite.onion. (4)

via tinyproxy: curl -i -x http://localhost:8888 http://***deadonionsite***.onion/ curl: (52) Empty reply from server

The (4) response code via Tor indicates host unreachable. Ideally tinyproxy would convey the same error instead of an empty response and, if required, reframe it for http.

rofl0r commented 2 years ago

unfortunately, the socks protocol doesn't provide a distinct error code for DNS resolution failure, so i can see why this happens. otoh an empty reply certainly isn't an adequate error for failure to connect to an upstream proxy. iirc we use 502 error code for a similar scenario; do you mind crafting a PR that does the same here ?