add latest rocksock
This commit is contained in:
15
rocksock.py
15
rocksock.py
@@ -179,7 +179,7 @@ def RocksockProxyFromURL(url):
|
|||||||
if x == -1: return None # port is obligatory
|
if x == -1: return None # port is obligatory
|
||||||
port = int(url[x+len(':'):]) #TODO: catch exception when port is non-numeric
|
port = int(url[x+len(':'):]) #TODO: catch exception when port is non-numeric
|
||||||
url = url[:x]
|
url = url[:x]
|
||||||
x = url.find('@')
|
x = url.rfind('@')
|
||||||
if x != -1:
|
if x != -1:
|
||||||
u, p = url[:x].split(':')
|
u, p = url[:x].split(':')
|
||||||
url = url[x+len('@'):]
|
url = url[x+len('@'):]
|
||||||
@@ -196,7 +196,13 @@ class Rocksock():
|
|||||||
if not verifycert: self.sslcontext.verify_mode = ssl.CERT_NONE
|
if not verifycert: self.sslcontext.verify_mode = ssl.CERT_NONE
|
||||||
else:
|
else:
|
||||||
self.sslcontext = None
|
self.sslcontext = None
|
||||||
self.proxychain = copy.copy(proxies) if proxies else []
|
self.proxychain = []
|
||||||
|
if proxies is not None:
|
||||||
|
for p in proxies:
|
||||||
|
if isinstance(p, basestring):
|
||||||
|
self.proxychain.append(RocksockProxyFromURL(p))
|
||||||
|
else:
|
||||||
|
self.proxychain.append(p)
|
||||||
target = RocksockProxy(host, port, RS_PT_NONE)
|
target = RocksockProxy(host, port, RS_PT_NONE)
|
||||||
self.proxychain.append(target)
|
self.proxychain.append(target)
|
||||||
self.sock = None
|
self.sock = None
|
||||||
@@ -276,7 +282,10 @@ class Rocksock():
|
|||||||
def send(self, buf, pnum=-1):
|
def send(self, buf, pnum=-1):
|
||||||
if self.sock is None:
|
if self.sock is None:
|
||||||
raise RocksockException(RS_E_NO_SOCKET, failedproxy=self._failed_proxy(pnum))
|
raise RocksockException(RS_E_NO_SOCKET, failedproxy=self._failed_proxy(pnum))
|
||||||
return self.sock.sendall(buf)
|
try:
|
||||||
|
return self.sock.sendall(buf)
|
||||||
|
except socket.error as e:
|
||||||
|
raise self._translate_socket_error(e, pnum)
|
||||||
|
|
||||||
def _get_ssl_exception_reason(self, e):
|
def _get_ssl_exception_reason(self, e):
|
||||||
s = ''
|
s = ''
|
||||||
|
|||||||
Reference in New Issue
Block a user