From: bert hubert Date: Sun, 29 Nov 2015 21:48:19 +0000 (+0100) Subject: add dynamic blocklist to the webpage X-Git-Tag: dnsdist-1.0.0-alpha1~170^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7be71139abc72ad372be1bd4c2e0cd4ef0f9071c;p=pdns add dynamic blocklist to the webpage --- diff --git a/pdns/dnsdist-web.cc b/pdns/dnsdist-web.cc index 28cc1327e..b2c6e23d9 100644 --- a/pdns/dnsdist-web.cc +++ b/pdns/dnsdist-web.cc @@ -100,6 +100,19 @@ static void connectionThread(int sock, ComboAddress remote, string password) resp.headers["Content-Type"] = "application/json"; resp.body=my_json.dump(); } + else if(command=="dynblocklist") { + resp.status=200; + + Json::object obj; + auto slow = g_dynblockNMG.getCopy(); + for(const auto& e: slow) { + obj.insert({e->first.toString(), e->second}); + } + Json my_json=obj; + + resp.headers["Content-Type"] = "application/json"; + resp.body=my_json.dump(); + } else if(req.url.path=="/servers/localhost") { resp.status=200; @@ -183,8 +196,6 @@ static void connectionThread(int sock, ComboAddress remote, string password) resp.body = callback + "(" + resp.body + ");"; } - - std::ostringstream ofs; ofs << resp; string done; diff --git a/pdns/dnsdistdist/html/index.html b/pdns/dnsdistdist/html/index.html index 9c27b990d..960adc495 100644 --- a/pdns/dnsdistdist/html/index.html +++ b/pdns/dnsdistdist/html/index.html @@ -85,6 +85,10 @@ Average response time: ms, CPU Usage:
+ +
+ + diff --git a/pdns/dnsdistdist/html/local.js b/pdns/dnsdistdist/html/local.js index 9e44f7656..6937d6c44 100644 --- a/pdns/dnsdistdist/html/local.js +++ b/pdns/dnsdistdist/html/local.js @@ -213,6 +213,17 @@ $(document).ready(function() { return; // updateRingBuffers(); + $.ajax({ url: 'jsonstat?command=dynblocklist', type: 'GET', dataType: 'json', + success: function(data) { + var bouw=""; + $.each(data, function(a,b) { + bouw=bouw+(""); + }); + bouw=bouw+"
NetmaskReason
"+a+""+b+"
"; + $("#dynblock").html(bouw); + + }}); + };