aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/socks.py
diff options
context:
space:
mode:
authorYen Chi Hsuan <yan12125@gmail.com>2017-04-22 21:44:01 +0800
committerYen Chi Hsuan <yan12125@gmail.com>2017-04-22 21:48:41 +0800
commit54f54fcca7af7e5bbc779cfc73d58d1ed2b4b6ae (patch)
tree67a344d3bee45099b1df3cc2b1ef58067d135a04 /youtube_dl/socks.py
parentfacfd79f9ad574db7bfcc90cbef01b3a7e7b1262 (diff)
downloadyoutube-dl-54f54fcca7af7e5bbc779cfc73d58d1ed2b4b6ae.tar.xz
[socks] Report errors elegantly when credentails are required but missing
In some non-standard implementations, the server may respond AUTH_USER_PASS even if's not listed in available authentication methods. (it should respond AUTH_NO_ACCEPTABLE per standards)
Diffstat (limited to 'youtube_dl/socks.py')
-rw-r--r--youtube_dl/socks.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/youtube_dl/socks.py b/youtube_dl/socks.py
index 0f5d7bdb2..5d4adbe72 100644
--- a/youtube_dl/socks.py
+++ b/youtube_dl/socks.py
@@ -193,9 +193,10 @@ class sockssocket(socket.socket):
self._check_response_version(SOCKS5_VERSION, version)
- if method == Socks5Auth.AUTH_NO_ACCEPTABLE:
+ if method == Socks5Auth.AUTH_NO_ACCEPTABLE or (
+ method == Socks5Auth.AUTH_USER_PASS and (not self._proxy.username or not self._proxy.password)):
self.close()
- raise Socks5Error(method)
+ raise Socks5Error(Socks5Auth.AUTH_NO_ACCEPTABLE)
if method == Socks5Auth.AUTH_USER_PASS:
username = self._proxy.username.encode('utf-8')