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