1
0
mirror of https://github.com/dkmstr/openuds.git synced 2024-12-22 13:34:04 +03:00

Fixed net to use only integers on py3

This commit is contained in:
Adolfo Gómez García 2018-01-18 08:32:16 +01:00
parent d0fb880880
commit 3420ac44be

View File

@ -59,12 +59,12 @@ def longToIp(n):
convert long int to dotted quad string convert long int to dotted quad string
''' '''
try: try:
d = 256 * 256 * 256 d = 1 << 24
q = [] q = []
while d > 0: while d > 0:
m, n = divmod(n, d) m, n = divmod(n, d)
q.append(str(m)) q.append(str(m)) # As m is an integer, this works on py2 and p3 correctly
d = d / 256 d >>= 8
return '.'.join(q) return '.'.join(q)
except: except:
@ -97,7 +97,7 @@ def networksFromString(strNets, allowMultipleNetworks=True):
val = 0 val = 0
for n in args: for n in args:
val += start * int(n) val += start * int(n)
start /= 256 start >>= 8
return val return val
def maskFromBits(nBits): def maskFromBits(nBits):