mirror of
https://github.com/sshuttle/sshuttle.git
synced 2025-03-14 16:19:01 +01:00
Implement our own left-shift operator to shut up python 2.3 warnings.
Apparently left-shift in python 2.3 just *always* prints a warning, even if we weren't doing anything wrong. Or maybe it only prints the warning sometimes. Anyway, let's just multiply by 2**x instead of using <<x, since we're not performance-sensitive anyway.
This commit is contained in:
parent
c403a83ab8
commit
b0f061e204
@ -40,6 +40,10 @@ def _maskbits(netmask):
|
||||
if netmask[0] & (1<<i):
|
||||
return 32-i
|
||||
return 0
|
||||
|
||||
|
||||
def _shl(n, bits):
|
||||
return n * int(2**bits)
|
||||
|
||||
|
||||
def _list_routes():
|
||||
@ -54,7 +58,7 @@ def _list_routes():
|
||||
maskw = _ipmatch(cols[2]) # linux only
|
||||
mask = _maskbits(maskw) # returns 32 if maskw is null
|
||||
width = min(ipw[1], mask)
|
||||
ip = ipw[0] & (((1<<width)-1) << (32-width))
|
||||
ip = ipw[0] & _shl(_shl(1, width) - 1, 32-width)
|
||||
routes.append((socket.inet_ntoa(struct.pack('!I', ip)), width))
|
||||
rv = p.wait()
|
||||
if rv != 0:
|
||||
|
Loading…
Reference in New Issue
Block a user