summaryrefslogtreecommitdiffstats
path: root/luci-app-cjdns/luasrc/model/cbi/cjdns/cjdrouteconf.lua
blob: 00e9ae00372604539602953e23c966e93816a8a5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
m = Map("cjdns", translate("cjdns"),
  translate("Implements an encrypted IPv6 network using public-key \
    cryptography for address allocation and a distributed hash table for \
    routing. This provides near-zero-configuration networking, and prevents \
    many of the security and scalability issues that plague existing \
    networks."))

dkjson = require("dkjson")
cjdns = require("cjdns")
require("cjdns/uci")

local f = SimpleForm("cjdrouteconf", translate("Edit cjdroute.conf"),
	translate("JSON interface to what's /etc/cjdroute.conf on other systems. \
    Will be parsed and written to UCI by <code>cjdrouteconf set</code>."))

local o = f:field(Value, "_cjdrouteconf")
o.template = "cbi/tvalue"
o.rows = 25

function o.cfgvalue(self, section)
	return dkjson.encode(cjdns.uci.get(), { indent = true })
end

function o.write(self, section, value)
  local obj, pos, err = dkjson.decode(value, 1, nil)

  if obj then
    cjdns.uci.set(obj)
  end
end

return f