coding standards
This commit is contained in:
parent
19bc86d9a3
commit
a3d772e505
|
@ -142,16 +142,14 @@ class SocksQueue:
|
|||
if receiving:
|
||||
self.type = 'receiver'
|
||||
socks5obj = Socks5Receiver(self.idlequeue, streamhost, sid,
|
||||
'client', file_props,
|
||||
fingerprint=fp)
|
||||
'client', file_props, fingerprint=fp)
|
||||
self.add_sockobj(account, socks5obj)
|
||||
else:
|
||||
self.type = 'sender'
|
||||
socks5obj = Socks5Sender(self.idlequeue,
|
||||
file_props['sha_str'], self, mode='client' ,
|
||||
_sock=None, host=str(streamhost['host']),
|
||||
port=int(streamhost['port']), fingerprint=fp,
|
||||
connected=False, file_props=file_props)
|
||||
socks5obj = Socks5Sender(self.idlequeue, file_props['sha_str'],
|
||||
self, mode='client' , _sock=None,
|
||||
host=str(streamhost['host']), port=int(streamhost['port']),
|
||||
fingerprint=fp, connected=False, file_props=file_props)
|
||||
socks5obj.streamhost = streamhost
|
||||
self.add_sockobj(account, socks5obj, type='sender')
|
||||
|
||||
|
@ -266,7 +264,6 @@ class SocksQueue:
|
|||
keys = (fp['sid'], fp['name'], hash)
|
||||
sockobjects[keys] = sockobj
|
||||
|
||||
|
||||
def result_sha(self, sha_str, idx):
|
||||
if sha_str in self.sha_handlers:
|
||||
props = self.sha_handlers[sha_str]
|
||||
|
@ -319,7 +316,6 @@ class SocksQueue:
|
|||
file_props['received-len'] = 0
|
||||
sender.file_props = file_props
|
||||
|
||||
|
||||
def add_file_props(self, account, file_props):
|
||||
"""
|
||||
File_prop to the dict of current file_props. It is identified by account
|
||||
|
@ -369,9 +365,9 @@ class SocksQueue:
|
|||
if self.type == 'sender' and \
|
||||
not self.isHashInSockObjs(self.senders, sock_hash):
|
||||
|
||||
sockobj = Socks5Sender(self.idlequeue, sock_hash, self,
|
||||
'server', sock[0], sock[1][0], sock[1][1],
|
||||
fingerprint='server', file_props=listener.file_props)
|
||||
sockobj = Socks5Sender(self.idlequeue, sock_hash, self, 'server',
|
||||
sock[0], sock[1][0], sock[1][1], fingerprint='server',
|
||||
file_props=listener.file_props)
|
||||
self._add(sockobj, self.senders, listener.file_props, sock_hash)
|
||||
# Start waiting for data
|
||||
self.idlequeue.plug_idle(sockobj, False, True)
|
||||
|
@ -386,8 +382,7 @@ class SocksQueue:
|
|||
sh['target'] = None
|
||||
|
||||
sockobj = Socks5Receiver(idlequeue=self.idlequeue,
|
||||
streamhost=sh,sid=None,
|
||||
file_props=listener.file_props,
|
||||
streamhost=sh,sid=None, file_props=listener.file_props,
|
||||
mode='server',fingerprint='server')
|
||||
|
||||
self._add(sockobj, self.readers, listener.file_props, sock_hash)
|
||||
|
@ -532,8 +527,8 @@ class Socks5:
|
|||
errnum = ee[0]
|
||||
self.connect_timeout += 1
|
||||
if errnum == 111 or self.connect_timeout > 1000:
|
||||
self.queue._connection_refused(self.streamhost,
|
||||
self.file_props, self.queue_idx)
|
||||
self.queue._connection_refused(self.streamhost, self.file_props,
|
||||
self.queue_idx)
|
||||
self.connected = False
|
||||
return None
|
||||
# win32 needs this
|
||||
|
@ -714,7 +709,6 @@ class Socks5:
|
|||
|
||||
|
||||
def pollin(self):
|
||||
|
||||
if self.mode == 'client':
|
||||
self.clnt_pollin()
|
||||
elif self.mode == 'server':
|
||||
|
@ -781,7 +775,6 @@ class Socks5:
|
|||
|
||||
|
||||
def pollend(self):
|
||||
|
||||
if self.mode == 'client':
|
||||
self.clnt_pollend()
|
||||
elif self.mode == 'server':
|
||||
|
@ -1081,10 +1074,12 @@ class Socks5:
|
|||
return struct.pack('!BB', 0x05, 0x00)
|
||||
|
||||
def _get_connect_buff(self):
|
||||
''' Connect request by domain name '''
|
||||
"""
|
||||
Connect request by domain name
|
||||
"""
|
||||
buff = struct.pack('!BBBBB%dsBB' % len(self.host),
|
||||
0x05, 0x01, 0x00, 0x03, len(self.host), self.host,
|
||||
self.port >> 8, self.port & 0xff)
|
||||
0x05, 0x01, 0x00, 0x03, len(self.host), self.host, self.port >> 8,
|
||||
self.port & 0xff)
|
||||
return buff
|
||||
|
||||
def _get_request_buff(self, msg, command = 0x01):
|
||||
|
@ -1162,8 +1157,7 @@ class Socks5Sender(Socks5, IdleObject):
|
|||
"""
|
||||
|
||||
def __init__(self, idlequeue, sock_hash, parent, mode,_sock, host=None,
|
||||
port=None, fingerprint = None, connected=True,
|
||||
file_props={}):
|
||||
port=None, fingerprint = None, connected=True, file_props={}):
|
||||
|
||||
self.fingerprint = fingerprint
|
||||
self.queue_idx = sock_hash
|
||||
|
@ -1261,7 +1255,8 @@ class Socks5Listener(IdleObject):
|
|||
This class implements IdleObject, but we will expect
|
||||
only pollin events though
|
||||
|
||||
fingerprint: fingerprint of certificates we shall use, set to None if TLS connection not desired
|
||||
fingerprint: fingerprint of certificates we shall use, set to None if
|
||||
TLS connection not desired
|
||||
"""
|
||||
self.port = port
|
||||
self.ais = socket.getaddrinfo(None, port, socket.AF_UNSPEC,
|
||||
|
@ -1356,7 +1351,8 @@ class Socks5Receiver(Socks5, IdleObject):
|
|||
def __init__(self, idlequeue, streamhost, sid, mode, file_props = None,
|
||||
fingerprint=None):
|
||||
"""
|
||||
fingerprint: fingerprint of certificates we shall use, set to None if TLS connection not desired
|
||||
fingerprint: fingerprint of certificates we shall use, set to None if
|
||||
TLS connection not desired
|
||||
"""
|
||||
self.queue_idx = -1
|
||||
self.streamhost = streamhost
|
||||
|
|
Loading…
Reference in New Issue