示例#1
0
 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))
示例#2
0
文件: views.py 项目: NotSqrt/binder
 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)
示例#3
0
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})
示例#4
0
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})
示例#5
0
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})
示例#6
0
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
    })