luci-app-unbound: dispatch SimpleForm models using the form() action
[project/luci.git] / applications / luci-app-unbound / luasrc / controller / unbound.lua
index 296d020..730ca72 100644 (file)
@@ -8,7 +8,7 @@ module("luci.controller.unbound", package.seeall)
 
 function index()
   local ucl = luci.model.uci.cursor()
-  local valexp = ucl:get_first("unbound", "unbound", "luci_expanded")
+  local valexp = ucl:get_first("unbound", "unbound", "extended_luci")
   local valman = ucl:get_first("unbound", "unbound", "manual_conf")
 
 
@@ -47,12 +47,12 @@ function index()
     if valman ~= "1" then
       entry({"admin", "services", "unbound", "files", "base"}, call("ShowUnboundConf"), _("UCI: Unbound"), 10).leaf = true
     else
-      entry({"admin", "services", "unbound", "files", "base"}, cbi("unbound/manual"), _("Edit: Unbound"), 10).leaf = true
+      entry({"admin", "services", "unbound", "files", "base"}, form("unbound/manual"), _("Edit: Unbound"), 10).leaf = true
     end
 
 
-    entry({"admin", "services", "unbound", "files", "server"}, cbi("unbound/server"), _("Edit: Server"), 20).leaf = true
-    entry({"admin", "services", "unbound", "files", "extended"}, cbi("unbound/extended"), _("Edit: Extended"), 30).leaf = true
+    entry({"admin", "services", "unbound", "files", "server"}, form("unbound/server"), _("Edit: Server"), 20).leaf = true
+    entry({"admin", "services", "unbound", "files", "extended"}, form("unbound/extended"), _("Edit: Extended"), 30).leaf = true
 
 
     if nixio.fs.access("/var/lib/unbound/unbound_dhcp.conf") then
@@ -89,7 +89,7 @@ end
 function QueryStatistics()
   local lclhead = "Unbound Control Stats"
   local lcldata = luci.util.exec("unbound-control -c /var/lib/unbound/unbound.conf stats_noreset")
-  local lcldesc = luci.i18n.translate("This shows some performances statistics tracked by Unbound.")
+  local lcldesc = luci.i18n.translate("This shows some performance statistics tracked by Unbound.")
   luci.template.render("unbound/show-textbox", {heading = lclhead, description = lcldesc, content = lcldata})
 end
 
@@ -97,7 +97,7 @@ end
 function QueryLocalData()
   local lclhead = "Unbound Control Local Data"
   local lcldata = luci.util.exec("unbound-control -c /var/lib/unbound/unbound.conf list_local_data")
-  local lcldesc = luci.i18n.translate("This shows local RR including this router, DHCP assignments, and RFC1918 SOA stubs.")
+  local lcldesc = luci.i18n.translate("This shows local host records that shortcut recursion.")
   luci.template.render("unbound/show-textbox", {heading = lclhead, description = lcldesc, content = lcldata})
 end
 
@@ -105,31 +105,47 @@ end
 function QueryLocalZone()
   local lclhead = "Unbound Control Local Zones"
   local lcldata = luci.util.exec("unbound-control -c /var/lib/unbound/unbound.conf list_local_zones")
-  local lcldesc = luci.i18n.translate("This shows local zones including LAN, adblock, forwarding, and RFC1918 in-arpa. ")
+  local lcldesc = luci.i18n.translate("This shows local zone definitions that affect recursion routing or processing. ")
   luci.template.render("unbound/show-textbox", {heading = lclhead, description = lcldesc, content = lcldata})
 end
 
 
 function ShowUnboundConf()
+  local unboundfile = "/var/lib/unbound/unbound.conf"
   local lclhead = "Unbound Conf"
-  local lcldata = luci.util.exec("cat /var/lib/unbound/unbound.conf")
-  local lcldesc = luci.i18n.translate("This shows '/var/lib/unbound/unbound.conf' generated by UCI.")
+  local lcldata = nixio.fs.readfile(unboundfile)
+  local lcldesc = luci.i18n.translate("This shows configuration generated by UCI:")
+  lcldesc = lcldesc .. " (" .. unboundfile .. ")"
   luci.template.render("unbound/show-textbox", {heading = lclhead, description = lcldesc, content = lcldata})
 end
 
 
 function ShowDHCPConf()
+  local dhcpfile = "/var/lib/unbound/unbound_dhcp.conf"
   local lclhead = "DHCP Conf"
-  local lcldata = luci.util.exec("cat /var/lib/unbound/unbound_dhcp.conf")
-  local lcldesc = luci.i18n.translate("This shows '/var/lib/unbound/unbound_dhcp.conf' generated by DHCP hook script(s).")
+  local lcldata = nixio.fs.readfile(dhcpfile)
+  local lcldesc = luci.i18n.translate("This shows LAN hosts added by DHCP hook scripts:")
+  lcldesc = lcldesc .. " (" .. dhcpfile .. ")"
   luci.template.render("unbound/show-textbox", {heading = lclhead, description = lcldesc, content = lcldata})
 end
 
 
 function ShowAdblock()
+  local adblockfile = "/var/lib/unbound/adb_list.overall"
   local lclhead = "Adblock Conf"
-  local lcldata = luci.util.exec("cat /var/lib/unbound/adb_list.overall")
-  local lcldesc = luci.i18n.translate("This shows '/var/lib/unbound/adb_list.overall' provided by Adblock script(s).")
-  luci.template.render("unbound/show-textbox", {heading = lclhead, description = lcldesc, content = lcldata})
+  local lcldata, lcldesc
+
+
+  if nixio.fs.stat(adblockfile).size > 262144 then
+    lcldesc = luci.i18n.translate("Adblock domain list is too large for LuCI:")
+    lcldesc = lcldesc .. " (" .. adblockfile .. ")"
+    luci.template.render("unbound/show-empty", {heading = lclhead, description = lcldesc})
+
+  else
+    lcldata = nixio.fs.readfile(adblockfile)
+    lcldesc = luci.i18n.translate("This shows blocked domains provided by Adblock scripts:")
+    lcldesc = lcldesc .. " (" .. adblockfile .. ")"
+    luci.template.render("unbound/show-textbox", {heading = lclhead, description = lcldesc, content = lcldata})
+  end
 end