From 596312c2449c0210416ae50e65f40ad6d1e418e7 Mon Sep 17 00:00:00 2001 From: whew <73732390+whew@users.noreply.github.com> Date: Sat, 6 Feb 2021 05:20:34 +0000 Subject: [PATCH 1/4] recognize socks5h --- youtube_dl/utils.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py index 8e4d144c9..447c2a3bb 100644 --- a/youtube_dl/utils.py +++ b/youtube_dl/utils.py @@ -76,7 +76,7 @@ def register_socks_protocols(): # "Register" SOCKS protocols # In Python < 2.6.5, urlsplit() suffers from bug https://bugs.python.org/issue7904 # URLs with protocols not in urlparse.uses_netloc are not handled correctly - for scheme in ('socks', 'socks4', 'socks4a', 'socks5'): + for scheme in ('socks', 'socks4', 'socks4a', 'socks5', 'socks5h'): if scheme not in compat_urlparse.uses_netloc: compat_urlparse.uses_netloc.append(scheme) @@ -2673,7 +2673,7 @@ def make_socks_conn_class(base_class, socks_proxy): compat_http_client.HTTPConnection, compat_http_client.HTTPSConnection)) url_components = compat_urlparse.urlparse(socks_proxy) - if url_components.scheme.lower() == 'socks5': + if url_components.scheme.lower() in ('socks5', 'socks5h'): socks_type = ProxyType.SOCKS5 elif url_components.scheme.lower() in ('socks', 'socks4'): socks_type = ProxyType.SOCKS4 @@ -5352,7 +5352,7 @@ class PerRequestProxyHandler(compat_urllib_request.ProxyHandler): if proxy == '__noproxy__': return None # No Proxy - if compat_urlparse.urlparse(proxy).scheme.lower() in ('socks', 'socks4', 'socks4a', 'socks5'): + if compat_urlparse.urlparse(proxy).scheme.lower() in ('socks', 'socks4', 'socks4a', 'socks5', 'socks5h'): req.add_header('Ytdl-socks-proxy', proxy) # youtube-dl's http/https handlers do wrapping the socket with socks return None From 3fedb4a58183543b397fc1d540b47646ee080172 Mon Sep 17 00:00:00 2001 From: whew <73732390+whew@users.noreply.github.com> Date: Sat, 6 Feb 2021 05:28:29 +0000 Subject: [PATCH 2/4] add test for socks5h like other socks protocols --- test/test_socks.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/test_socks.py b/test/test_socks.py index 1e68eb0da..50803c436 100644 --- a/test/test_socks.py +++ b/test/test_socks.py @@ -113,6 +113,8 @@ class TestSocks(unittest.TestCase): def test_socks5(self): self.assertTrue(isinstance(self._get_ip('socks5'), compat_str)) + def test_socks5h(self): + self.assertTrue(isinstance(self._get_ip('socks5h'), compat_str)) if __name__ == '__main__': unittest.main() From 37d9267d13d7666de49ff34a7a679499d960b157 Mon Sep 17 00:00:00 2001 From: whew <73732390+whew@users.noreply.github.com> Date: Sat, 6 Feb 2021 05:29:13 +0000 Subject: [PATCH 3/4] mention socks5h in --proxy help --- youtube_dl/options.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/youtube_dl/options.py b/youtube_dl/options.py index 241cf110f..4371fe027 100644 --- a/youtube_dl/options.py +++ b/youtube_dl/options.py @@ -205,7 +205,7 @@ def parseOpts(overrideArguments=None): default=None, metavar='URL', help='Use the specified HTTP/HTTPS/SOCKS proxy. To enable ' 'SOCKS proxy, specify a proper scheme. For example ' - 'socks5://127.0.0.1:1080/. Pass in an empty string (--proxy "") ' + 'socks5h://127.0.0.1:1080/. Pass in an empty string (--proxy "") ' 'for direct connection') network.add_option( '--socket-timeout', From acad161001f6f58a9e2dea499a635b48e455ff28 Mon Sep 17 00:00:00 2001 From: whew <73732390+whew@users.noreply.github.com> Date: Sat, 6 Feb 2021 05:29:44 +0000 Subject: [PATCH 4/4] mention socks5h in readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 94c34d89a..08f50890c 100644 --- a/README.md +++ b/README.md @@ -101,7 +101,7 @@ Alternatively, refer to the [developer instructions](#developer-instructions) fo --proxy URL Use the specified HTTP/HTTPS/SOCKS proxy. To enable SOCKS proxy, specify a proper scheme. For example - socks5://127.0.0.1:1080/. Pass in an + socks5h://127.0.0.1:1080/. Pass in an empty string (--proxy "") for direct connection --socket-timeout SECONDS Time to wait before giving up, in