projects
/
youtube-dl
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
[youtube] Add support for invidio.us (closes #17613)
[youtube-dl]
/
youtube_dl
/
socks.py
diff --git
a/youtube_dl/socks.py
b/youtube_dl/socks.py
index fd49d74352c7d50e15956169f686c3ffbb107b5c..5d4adbe72de5d273a11f0fc2d66b7829c4bbfb37 100644
(file)
--- a/
youtube_dl/socks.py
+++ b/
youtube_dl/socks.py
@@
-55,12
+55,12
@@
class Socks5AddressType(object):
ATYP_IPV6 = 0x04
ATYP_IPV6 = 0x04
-class ProxyError(
IOE
rror):
+class ProxyError(
socket.e
rror):
ERR_SUCCESS = 0x00
def __init__(self, code=None, msg=None):
if code is not None and msg is None:
ERR_SUCCESS = 0x00
def __init__(self, code=None, msg=None):
if code is not None and msg is None:
- msg = self.CODES.get(code)
and
'unknown error'
+ msg = self.CODES.get(code)
or
'unknown error'
super(ProxyError, self).__init__(code, msg)
super(ProxyError, self).__init__(code, msg)
@@
-76,7
+76,7
@@
class Socks4Error(ProxyError):
CODES = {
91: 'request rejected or failed',
CODES = {
91: 'request rejected or failed',
- 92: 'request rejected beca
su
e SOCKS server cannot connect to identd on the client',
+ 92: 'request rejected beca
us
e SOCKS server cannot connect to identd on the client',
93: 'request rejected because the client program and identd report different user-ids'
}
93: 'request rejected because the client program and identd report different user-ids'
}
@@
-103,6
+103,7
@@
class ProxyType(object):
SOCKS4A = 1
SOCKS5 = 2
SOCKS4A = 1
SOCKS5 = 2
+
Proxy = collections.namedtuple('Proxy', (
'type', 'host', 'port', 'username', 'password', 'remote_dns'))
Proxy = collections.namedtuple('Proxy', (
'type', 'host', 'port', 'username', 'password', 'remote_dns'))
@@
-122,7
+123,7
@@
class sockssocket(socket.socket):
while len(data) < cnt:
cur = self.recv(cnt - len(data))
if not cur:
while len(data) < cnt:
cur = self.recv(cnt - len(data))
if not cur:
- raise
IO
Error('{0} bytes missing'.format(cnt - len(data)))
+ raise
EOF
Error('{0} bytes missing'.format(cnt - len(data)))
data += cur
return data
data += cur
return data
@@
-192,9
+193,10
@@
class sockssocket(socket.socket):
self._check_response_version(SOCKS5_VERSION, version)
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()
self.close()
- raise Socks5Error(
method
)
+ raise Socks5Error(
Socks5Auth.AUTH_NO_ACCEPTABLE
)
if method == Socks5Auth.AUTH_USER_PASS:
username = self._proxy.username.encode('utf-8')
if method == Socks5Auth.AUTH_USER_PASS:
username = self._proxy.username.encode('utf-8')