dnscrypt-proxy.lua 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. -- Copyright 2017 Dirk Brenken (dev@brenken.org)
  2. -- This is free software, licensed under the Apache License, Version 2.0
  3. module("luci.controller.dnscrypt-proxy", package.seeall)
  4. local util = require("luci.util")
  5. local i18n = require("luci.i18n")
  6. local templ = require("luci.template")
  7. function index()
  8. if not nixio.fs.access("/etc/config/dnscrypt-proxy") then
  9. nixio.fs.writefile("/etc/config/dnscrypt-proxy", "")
  10. end
  11. entry({"admin", "services", "dnscrypt-proxy"}, firstchild(), _("DNSCrypt-Proxy"), 60).dependent = false
  12. entry({"admin", "services", "dnscrypt-proxy", "tab_from_cbi"}, cbi("dnscrypt-proxy/overview_tab", {hideresetbtn=true, hidesavebtn=true}), _("Overview"), 10).leaf = true
  13. entry({"admin", "services", "dnscrypt-proxy", "logfile"}, call("logread"), _("View Logfile"), 20).leaf = true
  14. entry({"admin", "services", "dnscrypt-proxy", "advanced"}, firstchild(), _("Advanced"), 100)
  15. entry({"admin", "services", "dnscrypt-proxy", "advanced", "configuration"}, cbi("dnscrypt-proxy/configuration_tab"), _("Edit DNSCrypt-Proxy Configuration"), 110).leaf = true
  16. entry({"admin", "services", "dnscrypt-proxy", "advanced", "cfg_dnsmasq"}, cbi("dnscrypt-proxy/cfg_dnsmasq_tab"), _("Edit Dnsmasq Configuration"), 120).leaf = true
  17. entry({"admin", "services", "dnscrypt-proxy", "advanced", "cfg_resolvcrypt"}, cbi("dnscrypt-proxy/cfg_resolvcrypt_tab"), _("Edit Resolvcrypt Configuration"), 130).leaf = true
  18. entry({"admin", "services", "dnscrypt-proxy", "advanced", "view_reslist"}, call("view_reslist"), _("View Resolver List"), 140).leaf = true
  19. end
  20. function view_reslist()
  21. local reslist = util.trim(util.exec("cat /usr/share/dnscrypt-proxy/dnscrypt-resolvers.csv"))
  22. templ.render("dnscrypt-proxy/view_reslist", {title = i18n.translate("DNSCrypt-Proxy Resolver List"), content = reslist})
  23. end
  24. function logread()
  25. local logfile
  26. if nixio.fs.access("/var/log/messages") then
  27. logfile = util.trim(util.exec("cat /var/log/messages | grep 'dnscrypt-proxy'"))
  28. else
  29. logfile = util.trim(util.exec("logread -e 'dnscrypt-proxy'"))
  30. end
  31. templ.render("dnscrypt-proxy/logread", {title = i18n.translate("DNSCrypt-Proxy Logfile"), content = logfile})
  32. end