Esempio n. 1
0
def gen_hosts(request):
    filename = "/tmp/__hosts.txt"
    hm = HostsManager()
    hm.generate_host_file(filename)

    from wsgiref.util import FileWrapper

    with open(filename, "r", encoding="utf-8") as myfile:
        # generate the file
        response = HttpResponse(FileWrapper(myfile), content_type='text/plain')
        response['Content-Disposition'] = 'attachment; filename=hosts.txt'
        return response
    return HttpResponse("error")
Esempio n. 2
0
def status(request):
    """View function for home page of site."""
    context = {
        'server_status': SecureDNSServer.isRunning(),
        'ttl_status': HostsManager.isTTLThreadRunning()
    }
    return render(request, 'status.html', context=context)
Esempio n. 3
0
def index(request):
    """View function for home page of site."""

    num_hosts = 0
    num_logs = 0
    hosts = None
    if db_table_exists("webui_host"):
        num_hosts = Host.objects.all().count()
        hosts = StatsHosts.objects.filter(hits__gt=1).order_by('-hits')
        num_logs = Logs.objects.all().count()

    context = {
        'num_hosts': num_hosts,
        'hosts': hosts,
        'num_logs': num_logs,
        'server_status': SecureDNSServer.isRunning(),
        'ttl_status': HostsManager.isTTLThreadRunning()
    }
    return render(request, 'index.html', context=context)
Esempio n. 4
0
def start_ttl(request):
    hm = HostsManager()
    hm.start_ttl_monitoring()
    hm.start_auto_update_hosts()
    hm.start_auto_backup()
    return HttpResponse("done")
Esempio n. 5
0
def update_yt(request):
    hm = HostsManager()
    hm.update_yt()
    return HttpResponse("done")
Esempio n. 6
0
def start_server(request):
    hm = HostsManager()
    hm.restore_backup()
    SecureDNSServer.start()
    return HttpResponse("done")
Esempio n. 7
0
def import_hosts(request):
    hm = HostsManager()
    hm.import_host_files("/tmp/hosts/")
    return HttpResponse("done")