simpleadblock.lua 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. m = Map("simple-adblock", translate("Simple AdBlock Settings"))
  2. s = m:section(NamedSection, "config", "simple-adblock")
  3. -- General options
  4. e = s:option(Flag, "enabled", translate("Enable/start service"))
  5. e.rmempty = false
  6. function e.cfgvalue(self, section)
  7. return self.map:get(section, "enabled") == "1" and luci.sys.init.enabled("simple-adblock") and self.enabled or self.disabled
  8. end
  9. function e.write(self, section, value)
  10. if value == "1" then
  11. luci.sys.call("/etc/init.d/simple-adblock enable >/dev/null")
  12. luci.sys.call("/etc/init.d/simple-adblock start >/dev/null")
  13. else
  14. luci.sys.call("/etc/init.d/simple-adblock stop >/dev/null")
  15. end
  16. return Flag.write(self, section, value)
  17. end
  18. o2 = s:option(ListValue, "verbosity", translate("Output Verbosity Setting"),translate("Controls system log and console output verbosity"))
  19. o2:value("0", translate("Suppress output"))
  20. o2:value("1", translate("Some output"))
  21. o2:value("2", translate("Verbose output"))
  22. o2.rmempty = false
  23. o2.default = 2
  24. o3 = s:option(ListValue, "force_dns", translate("Force Router DNS"), translate("Forces Router DNS use on local devices, also known as DNS Hijacking"))
  25. o3:value("0", translate("Let local devices use their own DNS servers if set"))
  26. o3:value("1", translate("Force Router DNS server to all local devices"))
  27. o3.rmempty = false
  28. o3.default = 1
  29. local sysfs_path = "/sys/class/leds/"
  30. local leds = {}
  31. if nixio.fs.access(sysfs_path) then
  32. leds = nixio.util.consume((nixio.fs.dir(sysfs_path)))
  33. end
  34. if #leds ~= 0 then
  35. o3 = s:option(Value, "led", translate("LED to indicate status"), translate("Pick the LED not already used in ")
  36. .. [[<a href="]] .. luci.dispatcher.build_url("admin/system/leds") .. [[">]]
  37. .. translate("System LED Configuration") .. [[</a>]])
  38. o3.rmempty = true
  39. o3:value("", translate("none"))
  40. for k, v in ipairs(leds) do
  41. o3:value(v)
  42. end
  43. end
  44. s2 = m:section(NamedSection, "config", "simple-adblock")
  45. -- Whitelisted Domains
  46. d1 = s2:option(DynamicList, "whitelist_domain", translate("Whitelisted Domains"), translate("Individual domains to be whitelisted"))
  47. d1.addremove = false
  48. d1.optional = false
  49. -- Blacklisted Domains
  50. d3 = s2:option(DynamicList, "blacklist_domain", translate("Blacklisted Domains"), translate("Individual domains to be blacklisted"))
  51. d3.addremove = false
  52. d3.optional = false
  53. -- Whitelisted Domains URLs
  54. d2 = s2:option(DynamicList, "whitelist_domains_url", translate("Whitelisted Domain URLs"), translate("URLs to lists of domains to be whitelisted"))
  55. d2.addremove = false
  56. d2.optional = false
  57. -- Blacklisted Domains URLs
  58. d4 = s2:option(DynamicList, "blacklist_domains_url", translate("Blacklisted Domain URLs"), translate("URLs to lists of domains to be blacklisted"))
  59. d4.addremove = false
  60. d4.optional = false
  61. -- Blacklisted Hosts URLs
  62. d5 = s2:option(DynamicList, "blacklist_hosts_url", translate("Blacklisted Hosts URLs"), translate("URLs to lists of hosts to be blacklisted"))
  63. d5.addremove = false
  64. d5.optional = false
  65. return m