Browse Source

fix PEP8

auth
clowwindy 10 years ago
parent
commit
972bf22e6d
  1. 4
      shadowsocks/asyncdns.py
  2. 3
      shadowsocks/common.py
  3. 3
      shadowsocks/encrypt.py
  4. 3
      shadowsocks/encrypt_salsa20.py
  5. 15
      shadowsocks/tcprelay.py
  6. 1
      tests/test_latency.py

4
shadowsocks/asyncdns.py

@ -403,8 +403,8 @@ class DNSResolver(object):
self._request_id = 1
req = build_request(hostname, qtype, self._request_id)
for server in self._servers:
logging.debug('resolving %s with type %d using server %s', hostname,
qtype, server)
logging.debug('resolving %s with type %d using server %s',
hostname, qtype, server)
self._sock.sendto(req, (server, 53))
def resolve(self, hostname, callback):

3
shadowsocks/common.py

@ -126,7 +126,8 @@ def parse_header(data):
else:
logging.warn('header is too short')
else:
logging.warn('unsupported addrtype %d, maybe wrong password' % addrtype)
logging.warn('unsupported addrtype %d, maybe wrong password' %
addrtype)
if dest_addr is None:
return None
return addrtype, dest_addr, dest_port, header_length

3
shadowsocks/encrypt.py

@ -154,7 +154,8 @@ class Encryptor(object):
iv = iv_
iv = iv[:m[1]]
if op == 1:
self.cipher_iv = iv[:m[1]] # this iv is for cipher not decipher
# this iv is for cipher not decipher
self.cipher_iv = iv[:m[1]]
if method != 'salsa20-ctr':
import M2Crypto.EVP
return M2Crypto.EVP.Cipher(method.replace('-', '_'), key, iv,

3
shadowsocks/encrypt_salsa20.py

@ -67,7 +67,8 @@ class Salsa20Cipher(object):
def _next_stream(self):
self._nonce &= 0xFFFFFFFFFFFFFFFF
self._stream = salsa20.Salsa20_keystream(BLOCK_SIZE,
struct.pack('<Q', self._nonce),
struct.pack('<Q',
self._nonce),
self._key)
self._nonce += 1

15
shadowsocks/tcprelay.py

@ -201,8 +201,9 @@ class TCPRelayHandler(object):
self._config['fast_open']:
try:
self._fastopen_connected = True
remote_sock = self._create_remote_socket(self._chosen_server[0],
self._chosen_server[1])
remote_sock = \
self._create_remote_socket(self._chosen_server[0],
self._chosen_server[1])
self._loop.add(remote_sock, eventloop.POLL_ERR)
data = ''.join(self._data_to_write_to_local)
l = len(data)
@ -497,8 +498,8 @@ class TCPRelay(object):
self._timeout = config['timeout']
self._timeouts = [] # a list for all the handlers
self._timeout_offset = 0 # last checked position for timeout
# we trim the timeouts once a while
# we trim the timeouts once a while
self._timeout_offset = 0 # last checked position for timeout
self._handler_to_timeouts = {} # key: handler value: index in timeouts
if is_local:
@ -606,9 +607,9 @@ class TCPRelay(object):
try:
logging.debug('accept')
conn = self._server_socket.accept()
TCPRelayHandler(self, self._fd_to_handlers, self._eventloop,
conn[0], self._config, self._dns_resolver,
self._is_local)
TCPRelayHandler(self, self._fd_to_handlers,
self._eventloop, conn[0], self._config,
self._dns_resolver, self._is_local)
except (OSError, IOError) as e:
error_no = eventloop.errno_from_exception(e)
if error_no in (errno.EAGAIN, errno.EINPROGRESS,

1
tests/test_latency.py

@ -10,4 +10,3 @@ for line in sys.stdin:
if 'HTTP/1.1 ' in line:
diff = time.time() - before
print 'headline %dms' % (diff * 1000)

Loading…
Cancel
Save