cjdrouteconf.lua 973 B

1234567891011121314151617181920212223242526272829303132
  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. dkjson = require("dkjson")
  8. cjdns = require("cjdns")
  9. require("cjdns/uci")
  10. local f = SimpleForm("cjdrouteconf", translate("Edit cjdroute.conf"),
  11. translate("JSON interface to what's /etc/cjdroute.conf on other systems. \
  12. Will be parsed and written to UCI by <code>cjdrouteconf set</code>."))
  13. local o = f:field(Value, "_cjdrouteconf")
  14. o.template = "cbi/tvalue"
  15. o.rows = 25
  16. function o.cfgvalue(self, section)
  17. return dkjson.encode(cjdns.uci.get(), { indent = true })
  18. end
  19. function o.write(self, section, value)
  20. local obj, pos, err = dkjson.decode(value, 1, nil)
  21. if obj then
  22. cjdns.uci.set(obj)
  23. end
  24. end
  25. return f