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: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F2960%2Fhead;p=thirdparty%2Fpdns.git add dynamic blocklist to the webpage --- diff --git a/pdns/dnsdist-web.cc b/pdns/dnsdist-web.cc index 28cc1327e3..b2c6e23d9a 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 9c27b990d9..960adc495e 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 9e44f7656e..6937d6c44e 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); + + }}); + };