From 7be71139abc72ad372be1bd4c2e0cd4ef0f9071c Mon Sep 17 00:00:00 2001 From: bert hubert Date: Sun, 29 Nov 2015 22:48:19 +0100 Subject: [PATCH] add dynamic blocklist to the webpage --- pdns/dnsdist-web.cc | 15 +++++++++++++-- pdns/dnsdistdist/html/index.html | 4 ++++ pdns/dnsdistdist/html/local.js | 11 +++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) 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); + + }}); + }; -- 2.47.2