fix indentation

This commit is contained in:
Yann Leboulanger 2012-06-20 23:58:08 +02:00
parent ee05914b30
commit 5d7ce867b4
1 changed files with 29 additions and 29 deletions

View File

@ -100,7 +100,7 @@ class SocksQueue:
# There is already a listener, we update the file's information # There is already a listener, we update the file's information
# on the new connection. # on the new connection.
self.listener.file_props = file_props self.listener.file_props = file_props
self.connected += 1 self.connected += 1
return self.listener return self.listener
@ -116,13 +116,13 @@ class SocksQueue:
return 0 return 0
streamhost['state'] = 1 streamhost['state'] = 1
self.on_success[file_props.sid](streamhost) self.on_success[file_props.sid](streamhost)
return 1 return 1
def connect_to_hosts(self, account, sid, on_success=None, on_failure=None, def connect_to_hosts(self, account, sid, on_success=None, on_failure=None,
fingerprint=None, receiving=True): fingerprint=None, receiving=True):
self.on_success[sid] = on_success self.on_success[sid] = on_success
self.on_failure[sid] = on_failure self.on_failure[sid] = on_failure
file_props = FilesProp.getFileProp(account, sid) file_props = FilesProp.getFileProp(account, sid)
file_props.failure_cb = on_failure file_props.failure_cb = on_failure
if not file_props.streamhosts: if not file_props.streamhosts:
@ -151,8 +151,8 @@ class SocksQueue:
file_props.proxy_sender = streamhost['target'] file_props.proxy_sender = streamhost['target']
file_props.proxy_receiver = streamhost['initiator'] file_props.proxy_receiver = streamhost['initiator']
socks5obj = Socks5SenderClient(self.idlequeue, idx, socks5obj = Socks5SenderClient(self.idlequeue, idx,
self, _sock=None,host=str(streamhost['host']), self, _sock=None,host=str(streamhost['host']),
port=int(streamhost['port']),fingerprint=fp, port=int(streamhost['port']),fingerprint=fp,
connected=False, file_props=file_props) connected=False, file_props=file_props)
socks5obj.streamhost = streamhost socks5obj.streamhost = streamhost
self.add_sockobj(account, socks5obj, type='sender') self.add_sockobj(account, socks5obj, type='sender')
@ -302,20 +302,20 @@ class SocksQueue:
def send_file(self, file_props, account, mode): def send_file(self, file_props, account, mode):
for key in self.senders.keys(): for key in self.senders.keys():
if self.senders == {}: if self.senders == {}:
# Python acts very weird with this. When there is no keys # Python acts very weird with this. When there is no keys
# in the dictionary It says that it has a key. # in the dictionary It says that it has a key.
# Maybe it is my machine. Without this there is a KeyError # Maybe it is my machine. Without this there is a KeyError
# traceback. # traceback.
return return
if file_props.name in key and file_props.sid in key \ if file_props.name in key and file_props.sid in key \
and self.senders[key].mode == mode: and self.senders[key].mode == mode:
log.info("socks5: sending file") log.info("socks5: sending file")
sender = self.senders[key] sender = self.senders[key]
file_props.streamhost_used = True file_props.streamhost_used = True
sender.account = account sender.account = account
sender.file_props = file_props sender.file_props = file_props
result = sender.send_file() result = sender.send_file()
self.process_result(result, sender) self.process_result(result, sender)
@ -323,7 +323,7 @@ class SocksQueue:
def remove_file_props(self, account, sid): def remove_file_props(self, account, sid):
fp = FilesProp.getFileProp(account, sid) fp = FilesProp.getFileProp(account, sid)
if not fp: if not fp:
log.warning('trying to remove a file props that doesnt exist ' + log.warning('trying to remove a file props that doesnt exist ' +
'from account ' + str(account) + ' and sid ' + str(sid)) 'from account ' + str(account) + ' and sid ' + str(sid))
return return
if sid in self.on_success: if sid in self.on_success:
@ -415,7 +415,7 @@ class SocksQueue:
del(self.readers[key]) del(self.readers[key])
if not remove_all: if not remove_all:
break break
def remove_sender(self, idx, do_disconnect=True, remove_all=False): def remove_sender(self, idx, do_disconnect=True, remove_all=False):
""" """
Remove sender from the list of senders and decrease the number of active Remove sender from the list of senders and decrease the number of active
@ -484,7 +484,7 @@ class Socks5:
for ai in self.ais: for ai in self.ais:
try: try:
self._sock = socket.socket(*ai[:3]) self._sock = socket.socket(*ai[:3])
if not self.fingerprint is None: if not self.fingerprint is None:
self._sock = OpenSSL.SSL.Connection( self._sock = OpenSSL.SSL.Connection(
jingle_xtls.get_context('client'), self._sock) jingle_xtls.get_context('client'), self._sock)
@ -696,7 +696,7 @@ class Socks5:
""" """
Read file contents from socket and write them to file Read file contents from socket and write them to file
""" """
if self.file_props is None or not self.file_props.file_name: if self.file_props is None or not self.file_props.file_name:
self.file_props.error = -2 self.file_props.error = -2
return None return None
@ -894,7 +894,7 @@ class Socks5:
""" """
Get sha of sid + Initiator jid + Target jid Get sha of sid + Initiator jid + Target jid
""" """
if self.file_props.is_a_proxy: if self.file_props.is_a_proxy:
self.file_props.is_a_proxy = None # Is this necesary? self.file_props.is_a_proxy = None # Is this necesary?
return hashlib.sha1('%s%s%s' % (self.sid, return hashlib.sha1('%s%s%s' % (self.sid,
@ -902,7 +902,7 @@ class Socks5:
self.file_props.proxy_receiver)).hexdigest() self.file_props.proxy_receiver)).hexdigest()
return hashlib.sha1('%s%s%s' % (self.sid, self.initiator, self.target)).\ return hashlib.sha1('%s%s%s' % (self.sid, self.initiator, self.target)).\
hexdigest() hexdigest()
class Socks5Sender(IdleObject): class Socks5Sender(IdleObject):
""" """
@ -928,7 +928,7 @@ class Socks5Sender(IdleObject):
jingle_xtls.get_context('server'), _sock) jingle_xtls.get_context('server'), _sock)
else: else:
self._sock.setblocking(False) self._sock.setblocking(False)
self.fd = _sock.fileno() self.fd = _sock.fileno()
self._recv = _sock.recv self._recv = _sock.recv
self._send = _sock.send self._send = _sock.send
@ -1022,7 +1022,7 @@ class Socks5Receiver(IdleObject):
self.file_props.continue_cb = self.continue_paused_transfer self.file_props.continue_cb = self.continue_paused_transfer
self.file_props.stalled = False self.file_props.stalled = False
self.file_props.received_len = 0 self.file_props.received_len = 0
def receive_file(self): def receive_file(self):
""" """
@ -1079,7 +1079,7 @@ class Socks5Server(Socks5):
def __init__(self, idlequeue, host, port, initiator, target, sid): def __init__(self, idlequeue, host, port, initiator, target, sid):
Socks5.__init__(self, idlequeue, host, port, initiator, target, sid) Socks5.__init__(self, idlequeue, host, port, initiator, target, sid)
self.mode = 'server' self.mode = 'server'
def main(self): def main(self):
@ -1183,7 +1183,7 @@ class Socks5Client(Socks5):
def __init__(self, idlequeue, host, port, initiator, target, sid): def __init__(self, idlequeue, host, port, initiator, target, sid):
Socks5.__init__(self, idlequeue, host, port, initiator, target, sid) Socks5.__init__(self, idlequeue, host, port, initiator, target, sid)
self.mode = 'client' self.mode = 'client'
def main(self, timeout=0): def main(self, timeout=0):
@ -1334,7 +1334,7 @@ class Socks5SenderClient(Socks5Client, Socks5Sender):
Socks5Client.__init__(self, idlequeue, host, port, None, None, Socks5Client.__init__(self, idlequeue, host, port, None, None,
file_props.sid) file_props.sid)
Socks5Sender.__init__(self,idlequeue, sock_hash, parent,_sock, Socks5Sender.__init__(self,idlequeue, sock_hash, parent,_sock,
host, port, fingerprint , connected, file_props) host, port, fingerprint , connected, file_props)
@ -1342,14 +1342,14 @@ class Socks5SenderClient(Socks5Client, Socks5Sender):
class Socks5SenderServer(Socks5Server, Socks5Sender): class Socks5SenderServer(Socks5Server, Socks5Sender):
def __init__(self, idlequeue, sock_hash, parent,_sock, host=None, def __init__(self, idlequeue, sock_hash, parent,_sock, host=None,
port=None, fingerprint = None, connected=True, file_props={}): port=None, fingerprint = None, connected=True, file_props={}):
Socks5Server.__init__(self, idlequeue, host, port, None, None, Socks5Server.__init__(self, idlequeue, host, port, None, None,
file_props.sid) file_props.sid)
Socks5Sender.__init__(self,idlequeue, sock_hash, parent, _sock, Socks5Sender.__init__(self,idlequeue, sock_hash, parent, _sock,
host, port, fingerprint , connected, file_props) host, port, fingerprint , connected, file_props)
@ -1359,14 +1359,14 @@ class Socks5ReceiverClient(Socks5Client, Socks5Receiver):
def __init__(self, idlequeue, streamhost, sid, file_props = None, def __init__(self, idlequeue, streamhost, sid, file_props = None,
fingerprint=None): fingerprint=None):
Socks5Client.__init__(self, idlequeue, streamhost['host'], Socks5Client.__init__(self, idlequeue, streamhost['host'],
int(streamhost['port']), streamhost['initiator'], int(streamhost['port']), streamhost['initiator'],
streamhost['target'], sid) streamhost['target'], sid)
Socks5Receiver.__init__(self, idlequeue, streamhost, sid, file_props, Socks5Receiver.__init__(self, idlequeue, streamhost, sid, file_props,
fingerprint) fingerprint)
class Socks5ReceiverServer(Socks5Server, Socks5Receiver): class Socks5ReceiverServer(Socks5Server, Socks5Receiver):
@ -1374,7 +1374,7 @@ class Socks5ReceiverServer(Socks5Server, Socks5Receiver):
fingerprint=None): fingerprint=None):
Socks5Server.__init__(self, idlequeue, streamhost['host'], Socks5Server.__init__(self, idlequeue, streamhost['host'],
int(streamhost['port']), streamhost['initiator'], int(streamhost['port']), streamhost['initiator'],
streamhost['target'], sid) streamhost['target'], sid)
Socks5Receiver.__init__(self, idlequeue, streamhost, sid, file_props, Socks5Receiver.__init__(self, idlequeue, streamhost, sid, file_props,