]> granicus.if.org Git - pdns/commitdiff
add dynamic blocklist to the webpage
authorbert hubert <bert.hubert@netherlabs.nl>
Sun, 29 Nov 2015 21:48:19 +0000 (22:48 +0100)
committerbert hubert <bert.hubert@netherlabs.nl>
Sun, 29 Nov 2015 21:48:19 +0000 (22:48 +0100)
pdns/dnsdist-web.cc
pdns/dnsdistdist/html/index.html
pdns/dnsdistdist/html/local.js

index 28cc1327e3534bbe462ddebe9f2188c6013bb6fc..b2c6e23d9a3614f13e762e1b77265a158c845a5c 100644 (file)
@@ -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;
index 9c27b990d925500042de1f0f57703d6995ed0305..960adc495e2dafa4e4352f5bbcec7287a4532f15 100644 (file)
@@ -85,6 +85,10 @@ Average response time: <span id="latency"></span> ms, CPU Usage: <span id="cpu">
          <td><div id="remotering"></div></td>
          <td><div id="servfailremotering"></div></td>
        </tr>
+       <tr>
+         <td><div id="dynblock"></div></td>
+       </tr>
+
       </table>
     </td>
   </tr>
index 9e44f7656e90a4ce564eb18296883ef4bfad8d97..6937d6c44eb321f5ac6cb2b5851573e9298265cf 100644 (file)
@@ -213,6 +213,17 @@ $(document).ready(function() {
            return;
 //     updateRingBuffers();
 
+       $.ajax({ url: 'jsonstat?command=dynblocklist', type: 'GET', dataType: 'json',
+                success: function(data) {
+                    var bouw="<table><tr align=left><th>Netmask</th><th align=left>Reason</th></tr>";
+                    $.each(data, function(a,b) {
+                        bouw=bouw+("<tr><td>"+a+"</td><td>"+b+"</td></tr>");
+                    });
+                    bouw=bouw+"</table>";
+                    $("#dynblock").html(bouw);
+
+                }});
+
 
     };