Browse Source

lint code

auth
clowwindy 10 years ago
parent
commit
0fd2f30911
  1. 2
      shadowsocks/common.py
  2. 2
      shadowsocks/crypto/salsa20_ctr.py
  3. 2
      shadowsocks/encrypt.py
  4. 3
      shadowsocks/server.py
  5. 3
      shadowsocks/tcprelay.py

2
shadowsocks/common.py

@ -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

2
shadowsocks/crypto/salsa20_ctr.py

@ -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)

2
shadowsocks/encrypt.py

@ -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

3
shadowsocks/server.py

@ -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:

3
shadowsocks/tcprelay.py

@ -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)

Loading…
Cancel
Save