def test_host():
    h1 = Host("192.168.0.1")
    h2 = Host("192.168.0.2")

    h1.link(h2)
    h2.link(h1)

    assert (h1 == "192.168.0.1")
    assert (h2 == "192.168.0.2")
    assert (h1.device_type() == Device_Type.HOST)
    assert (h2.device_type() == Device_Type.HOST)
    assert (h1.connected_router == h2)
    assert (h2.connected_router == h1)
示例#2
0
    def reverse_dns_on_cidr(target):
        """Does reverse dns lookups on a target, and saves results to target using target.add_related_host"""
        cidrs = set()
        if isinstance(target, Host):
            [cidrs.add(cidr) for cidr in target.cidrs]
        elif isinstance(target, Network):
            cidrs.add(target.cidr)
        else:
            raise ValueError

        for cidr in cidrs:

            for ip, reverse_domains in lookup.rev_dns_on_cidr(cidr):

                new_host = Host(ips=[ip], reverse_domains=reverse_domains)
                target.add_related_host(new_host)
                print new_host.print_all_ips()

        if not target.related_hosts:
            print '# No results for this range'
 def add_host(self, ip: str):
     self.hosts[ip] = Host(ip)
     self.devices[ip] = self.hosts[ip]