Browse Source

Fix for Python3 lambda behavior change

In Python3, lambda no longer support use tuple as syntax.
So, ugly changes is inevitable.
master
Sunny 10 years ago
parent
commit
b11d848986
  1. 4
      shadowsocks/common.py

4
shadowsocks/common.py

@ -226,12 +226,12 @@ class IPNetwork(object):
addr_family = is_ip(addr) addr_family = is_ip(addr)
if addr_family is socket.AF_INET: if addr_family is socket.AF_INET:
ip, = struct.unpack("!I", socket.inet_aton(addr)) ip, = struct.unpack("!I", socket.inet_aton(addr))
return any(map(lambda (n, ps): n == ip >> ps, return any(map(lambda n_ps: n_ps[0] == ip >> n_ps[1],
self._network_list_v4)) self._network_list_v4))
elif addr_family is socket.AF_INET6: elif addr_family is socket.AF_INET6:
hi, lo = struct.unpack("!QQ", inet_pton(addr_family, addr)) hi, lo = struct.unpack("!QQ", inet_pton(addr_family, addr))
ip = (hi << 64) | lo ip = (hi << 64) | lo
return any(map(lambda (n, ps): n == ip >> ps, return any(map(lambda n_ps: n_ps[0] == ip >> n_ps[1],
self._network_list_v6)) self._network_list_v6))
else: else:
return False return False

Loading…
Cancel
Save