Browse Source

lint code

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

2
shadowsocks/crypto/salsa20_ctr.py

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

2
shadowsocks/encrypt.py

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

3
shadowsocks/server.py

@ -70,7 +70,8 @@ def main():
def run_server(): def run_server():
def child_handler(signum, _): def child_handler(signum, _):
logging.warn('received SIGQUIT, doing graceful shutting down..') 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), signal.signal(getattr(signal, 'SIGQUIT', signal.SIGTERM),
child_handler) child_handler)
try: try:

3
shadowsocks/tcprelay.py

@ -268,7 +268,8 @@ class TCPRelayHandler(object):
self._stage = STAGE_DNS self._stage = STAGE_DNS
if self._is_local: if self._is_local:
# forward address to remote # 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) self._local_sock)
data_to_send = self._encryptor.encrypt(data) data_to_send = self._encryptor.encrypt(data)
self._data_to_write_to_remote.append(data_to_send) self._data_to_write_to_remote.append(data_to_send)

Loading…
Cancel
Save