Parcourir la source

Fix construction of packed CIDR mask from binary representation.

tags/v0.3
Ben Kurtovic il y a 8 ans
Parent
révision
623bf5a9a1
1 fichiers modifiés avec 3 ajouts et 1 suppressions
  1. +3
    -1
      earwigbot/commands/cidr.py

+ 3
- 1
earwigbot/commands/cidr.py Voir le fichier

@@ -111,9 +111,11 @@ class CIDR(Command):
break

mask = bin_ips[0][:size].ljust(len(bin_ips[0]), "0")
packed = "".join(
chr(int(mask[i:i + 8], 2)) for i in xrange(0, len(mask), 8))
return _Range(
family,
socket.inet_ntop(family, int(mask, 2)) + "/" + str(size),
socket.inet_ntop(family, packed) + "/" + str(size),
size,
self._format_count(2 ** (len(bin_ips[0]) - size)))



Chargement…
Annuler
Enregistrer