def test_ipinfo_ResolutionFail(self): response = helpers.ip_info("foobar.doesnotexist.local") self.assertEqual([['Error', u'Unable to resolve foobar.doesnotexist.local: [Errno -2] Name or service not known']], response) response = helpers.ip_info("localhost") self.assertEqual([['IPv4 (1)', u'127.0.0.1']], sorted(response))
def test_ipinfo_ResolutionFail(self): response = helpers.ip_info("foobar.doesnotexist.local") self.assertEqual([['Error', u'Unable to resolve foobar.doesnotexist.local: [Errno -2] Name or service not known']], response) # The following is currently the first globally unique IPv4 and IPv6 address I could find # that did not change based upon your geography. # http://test-ipv6.com/ response = helpers.ip_info("ds.test-ipv6.com") self.assertEqual([['IPv4 (1)', u'216.218.228.114'], ['IPv6 (1)', u'2001:470:1:18::2']], response)
def view_server_list(request): """ List the DNS servers configured in the database. """ server_list = models.BindServer.objects.all().order_by("hostname") server_info = [] for current in server_list: server_info.append({"host_name" : current, "ip_address" : helpers.ip_info(current.hostname)}) return render(request, "bcommon/list_servers.html", { "server_info" : server_info})
def view_server_list(request): """List the DNS servers configured in the database.""" server_list = models.BindServer.objects.all().order_by("hostname") server_info = [] for current in server_list: server_info.append({ "host_name": current, "ip_address": helpers.ip_info(current.hostname) }) return render(request, "bcommon/list_servers.html", {"server_info": server_info})
def view_query_history(request, dns_server): """View the query history of the choosen DNS server""" try: output = subprocess.check_output(["python", "query.py"]) except subprocess.CalledProcessError: server_list = models.BindServer.objects.all().order_by("hostname") server_info = [] for current in server_list: server_info.append({"host_name": current, "ip_address": helpers.ip_info(current.hostname)}) messages.error(request, "Can not found log file of %s" % dns_server) return redirect("server_list") else: output_list = output.split('\n') return render(request, "bcommon/history.html", {"output_list": output_list, "dns_server": dns_server})
def view_query_history(request, dns_server): """View the query history of the choosen DNS server""" try: output = subprocess.check_output(["python", "query.py"]) except subprocess.CalledProcessError: server_list = models.BindServer.objects.all().order_by("hostname") server_info = [] for current in server_list: server_info.append({ "host_name": current, "ip_address": helpers.ip_info(current.hostname) }) messages.error(request, "Can not found log file of %s" % dns_server) return redirect("server_list") else: output_list = output.split('\n') return render(request, "bcommon/history.html", { "output_list": output_list, "dns_server": dns_server })