def h2i(self, pkt, x): if type(x) is str: try: inet_aton(x) except socket.error: x = Net(x) elif type(x) is list: x = [self.h2i(pkt, n) for n in x] return x
def h2i(self, pkt, x): if isinstance(x, basestring): try: inet_aton(x) except socket.error: x = Net(x) elif type(x) is list: x = [self.h2i(pkt, n) for n in x] return x
class RandIP(RandString): """Generates a random IP address each time an instance is evaluated. Evaluate it manually by calling str() on it, or put it directly in a packet to generate a new random IP address each time the packet is evaluated. Call str() on it to get a single random IP address. Call str() on it again to get a different random IP address. The iptemplate field accepts a CIDR network mask.""" def __init__(self, iptemplate="0.0.0.0/0"): self.ip = Net(iptemplate) def _fix(self): return self.ip.choice()
def __init__(self, iptemplate="0.0.0.0/0"): self.ip = Net(iptemplate)
class RandIP(RandString): def __init__(self, iptemplate="0.0.0.0/0"): self.ip = Net(iptemplate) def _fix(self): return self.ip.choice()