ytdl-org/youtube-dl

Support for socks5h:// proxies

yurendry opened this issue · 0 comments

Checklist

  • I'm reporting a feature request
  • I've verified that I'm running youtube-dl version 2019.09.28
  • I've searched the bugtracker for similar feature requests including closed ones

Description

The difference between SOCKS5 and SOCKS5H is that SOCKS5H resolves DNS requests through the proxy and SOCKS5 resolves them locally. The DNS leak has technically been addressed in #9677 and it appears to been removed based on tests I carried out sniffing for DNS packets while running youtube-dl with --proxy socks5:// (this is the relevant line, I think).

So youtube-dl --proxy socks5:// behaves how youtube-dl --proxy socks5h:// should behave, and the latter misbehaves:

youtube-dl --proxy socks5h://127.0.0.1:9050 https://www.youtube.com/watch?v=BaW_jenozKc
[youtube] BaW_jenozKc: Downloading webpage
ERROR: Unable to download webpage: <urlopen error Tunnel connection failed: 501 Tor is not an HTTP Proxy> (caused by URLError(error('Tunnel connection failed: 501 Tor is not an HTTP Proxy',),))

I suggest that youtube-dl should accept the socks5h protocol and use for it the implementation of SOCKS5 that already exists (where DNS is resolved by the SOCKS server).

And maybe socks5's implementation should be changed to resolve DNS locally to honour the specification. The only issue I can see with fixing the names of the protocols is any scripts with socks5:// in them will start leaking DNS requests.