Add support for miniupnpd and cjdns
[librecmc/package-feed.git] / net / luci-app-cjdns / luasrc / model / cbi / cjdns / cjdrouteconf.lua
1 m = Map("cjdns", translate("cjdns"),
2   translate("Implements an encrypted IPv6 network using public-key \
3     cryptography for address allocation and a distributed hash table for \
4     routing. This provides near-zero-configuration networking, and prevents \
5     many of the security and scalability issues that plague existing \
6     networks."))
7
8 dkjson = require("dkjson")
9 cjdns = require("cjdns")
10 require("cjdns/uci")
11
12 local f = SimpleForm("cjdrouteconf", translate("Edit cjdroute.conf"),
13         translate("JSON interface to what's /etc/cjdroute.conf on other systems. \
14     Will be parsed and written to UCI by <code>cjdrouteconf set</code>."))
15
16 local o = f:field(Value, "_cjdrouteconf")
17 o.template = "cbi/tvalue"
18 o.rows = 25
19
20 function o.cfgvalue(self, section)
21         return dkjson.encode(cjdns.uci.get(), { indent = true })
22 end
23
24 function o.write(self, section, value)
25   local obj, pos, err = dkjson.decode(value, 1, nil)
26
27   if obj then
28     cjdns.uci.set(obj)
29   end
30 end
31
32 return f