luci-app-unbound: add cache_dump tab 2157/head
authorAnsuel Smith <ansuelsmth@gmail.com>
Tue, 18 Sep 2018 10:17:19 +0000 (12:17 +0200)
committerAnsuel Smith <ansuelsmth@gmail.com>
Tue, 18 Sep 2018 15:31:25 +0000 (17:31 +0200)
This adds in the State tab a new option to dump cache from unbound-control application

Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
applications/luci-app-unbound/luasrc/controller/unbound.lua

index 771385b7981d32dec3d0320b027d6bc77d754ea7..734476acaeaa5cea13e85fbd18df462800714b08 100644 (file)
@@ -52,6 +52,8 @@ function index()
         entry({"admin", "services", "unbound", "status", "localzone"},
             call("QueryLocalZone"), _("Local Zones"), 30).leaf = true
 
+        entry({"admin", "services", "unbound", "status", "dumpcache"},
+            call("QueryCacheDump"), _("Cache Dump"), 40).leaf = true
     else
         entry({"admin", "services", "unbound", "status", "statistics"},
             call("ShowEmpty"), _("Statistics"), 10).leaf = true
@@ -151,6 +153,16 @@ function QueryLocalZone()
         {heading = "", description = lcldesc, content = lcldata})
 end
 
+function QueryCacheDump()
+    local lcldata = luci.util.exec(
+        "unbound-control -c /var/lib/unbound/unbound.conf dump_cache")
+
+    local lcldesc = luci.i18n.translate(
+        "This shows Unbound 'cache_dump'. Usefull to check if unbound is actually caching dns entities.")
+
+    luci.template.render("unbound/show-textbox",
+        {heading = "", description = lcldesc, content = lcldata})
+end
 
 function ShowUnboundConf()
     local unboundfile = "/var/lib/unbound/unbound.conf"