lint code

This commit is contained in:
clowwindy 2014-10-31 18:43:15 +08:00
parent b409c18877
commit 0fd2f30911
5 changed files with 7 additions and 5 deletions

View file

@ -52,7 +52,7 @@ def inet_ntop(family, ipstr):
return socket.inet_ntoa(ipstr)
elif family == socket.AF_INET6:
v6addr = b':'.join((b'%02X%02X' % (ord(i), ord(j)))
for i, j in zip(ipstr[::2], ipstr[1::2]))
for i, j in zip(ipstr[::2], ipstr[1::2]))
return v6addr

View file

@ -72,7 +72,7 @@ def numpy_xor(a, b):
def py_xor_str(a, b):
c = []
for i in xrange(0, len(a)):
for i in range(0, len(a)):
c.append(chr(ord(a[i]) ^ ord(b[i])))
return ''.join(c)

View file

@ -61,7 +61,7 @@ def get_table(key):
s = m.digest()
(a, b) = struct.unpack('<QQ', s)
table = [c for c in string.maketrans('', '')]
for i in xrange(1, 1024):
for i in range(1, 1024):
table.sort(lambda x, y: int(a % (ord(x) + i) - a % (ord(y) + i)))
return table

View file

@ -70,7 +70,8 @@ def main():
def run_server():
def child_handler(signum, _):
logging.warn('received SIGQUIT, doing graceful shutting down..')
list(map(lambda s: s.close(next_tick=True), tcp_servers + udp_servers))
list(map(lambda s: s.close(next_tick=True),
tcp_servers + udp_servers))
signal.signal(getattr(signal, 'SIGQUIT', signal.SIGTERM),
child_handler)
try:

View file

@ -268,7 +268,8 @@ class TCPRelayHandler(object):
self._stage = STAGE_DNS
if self._is_local:
# forward address to remote
self._write_to_sock(b'\x05\x00\x00\x01\x00\x00\x00\x00\x10\x10',
self._write_to_sock((b'\x05\x00\x00\x01'
b'\x00\x00\x00\x00\x10\x10'),
self._local_sock)
data_to_send = self._encryptor.encrypt(data)
self._data_to_write_to_remote.append(data_to_send)