cfg_dnsmasq_tab.lua 983 B

12345678910111213141516171819202122232425262728293031323334353637
  1. -- Copyright 2017 Dirk Brenken (dev@brenken.org)
  2. -- This is free software, licensed under the Apache License, Version 2.0
  3. local nxfs = require("nixio.fs")
  4. local util = require("luci.util")
  5. local uci_input = "/etc/config/dhcp"
  6. if not nxfs.access(uci_input) then
  7. m = SimpleForm("error", nil, translate("Input file not found, please check your configuration."))
  8. return m
  9. end
  10. m = SimpleForm("input", nil)
  11. m:append(Template("dnscrypt-proxy/config_css"))
  12. m.submit = translate("Save")
  13. m.reset = false
  14. s = m:section(SimpleSection, nil,
  15. translate("This form allows you to modify the content of the main Dnsmasq configuration file (/etc/config/dhcp)."))
  16. f = s:option(TextValue, "data")
  17. f.rows = 20
  18. f.rmempty = true
  19. function f.cfgvalue()
  20. return nxfs.readfile(uci_input) or ""
  21. end
  22. function f.write(self, section, data)
  23. return nxfs.writefile(uci_input, "\n" .. util.trim(data:gsub("\r\n", "\n")) .. "\n")
  24. end
  25. function s.handle(self, state, data)
  26. return true
  27. end
  28. return m