Example #1
0
def test_mixed():
    logger = getLogger("root")
    testcase = "google.com 192.168.242.10 edenwall.com 88.6.4.2 yahoo.de".split()
    ns_ips = ("192.168.33.2",)
    result = iterable2ipset(logger, testcase, ns_ips)
    #cannot assert about len when we give names
    assert all(isinstance(item, IP) for item in result)
Example #2
0
def test_pureips():
    logger = getLogger("root")
    testcase = tuple(IP(item) for item in "0 192.168.9.12 227.90.1.2 aa:bb:cc::dd".split())
    ns_ips = ("192.168.33.2",)
    result = iterable2ipset(logger, testcase, ns_ips)
    assert len(result) == len(testcase)
    assert all(isinstance(item, IP) for item in result)
Example #3
0
    def _getForwardedDomains(
        self,
        responsible,
        ad_domain,
        ad_controller_ips,
        global_nameservers
        ):

        ns_ips = list(global_nameservers) #copy
        #append ips to global nameservers in this particular operation:
        to_resolve = set()
        helpers = set()
        for item in ad_controller_ips.split():
            try:
                ip = IP(item)
            except Exception:
                to_resolve.add(item)
                continue
            item = str(ip)
            helpers.add(item)
            ns_ips.append(item)

        if helpers and to_resolve:
            responsible.feedback(tr(
                "We can use [%s] to resolve [%s]" % (
                    ', '.join(helpers), ', '.join(to_resolve)
                    )
                ))

        try:
            resolved_ips = iterable2ipset(
                    self,
                    ad_controller_ips.split(),
                    ns_ips,
                    )
        except UnresolvableHost, err:
            if helpers:
                responsible.feedback(
                    _FEEDBACK_DNSERROR_W_HELPERS,
                    name=err.unresolvable,
                    dns_servers_list=', '.join(ns_ips),
                    dns_additionnal_list=', '.join(helpers),
                    )
            else:
                responsible.feedback(
                    _FEEDBACK_DNSERROR_WO_HELPERS,
                    name=err.unresolvable,
                    dns_servers_list=', '.join(ns_ips),
                    )
            raise DNSError("Unresolvable host: %s" % err.unresolvable)