peering.lua 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. uci = require "luci.model.uci"
  2. cursor = uci:cursor_state()
  3. cjdns = require("cjdns")
  4. require("cjdns/uci")
  5. m = Map("cjdns", translate("cjdns"),
  6. translate("Implements an encrypted IPv6 network using public-key \
  7. cryptography for address allocation and a distributed hash table for \
  8. routing. This provides near-zero-configuration networking, and prevents \
  9. many of the security and scalability issues that plague existing \
  10. networks."))
  11. m.on_after_commit = function(self)
  12. os.execute("/etc/init.d/cjdns restart")
  13. end
  14. -- Authorized Passwords
  15. passwords = m:section(TypedSection, "password", translate("Authorized Passwords"),
  16. translate("Anyone offering one of the these passwords will be allowed to peer with you on the existing UDP and Ethernet interfaces."))
  17. passwords.anonymous = true
  18. passwords.addremove = true
  19. passwords.template = "cbi/tblsection"
  20. passwords:option(Value, "user", translate("User/Name"),
  21. translate("Must be unique.")
  22. ).default = "user-" .. cjdns.uci.random_string(6)
  23. passwords:option(Value, "contact", translate("Contact"), translate("Optional, for out-of-band communication."))
  24. passwords:option(Value, "password", translate("Password"),
  25. translate("Hand out to your peer, in accordance with the peering best practices of the network.")
  26. ).default = cjdns.uci.random_string(32)
  27. -- UDP Peers
  28. udp_peers = m:section(TypedSection, "udp_peer", translate("Outgoing UDP Peers"),
  29. translate("For peering via public IP networks, the peer handed you their Public Key and IP address/port along with a password. IPv6 addresses should be entered with square brackets, like so: <code>[2001::1]</code>."))
  30. udp_peers.anonymous = true
  31. udp_peers.addremove = true
  32. udp_peers.template = "cbi/tblsection"
  33. udp_peers:option(Value, "user", translate("User/Name")).datatype = "string"
  34. udp_interface = udp_peers:option(Value, "interface", translate("UDP interface"))
  35. local index = 1
  36. for i,section in pairs(cursor:get_all("cjdns")) do
  37. if section[".type"] == "udp_interface" then
  38. udp_interface:value(index, section.address .. ":" .. section.port)
  39. end
  40. end
  41. udp_interface.default = 1
  42. udp_peers:option(Value, "address", translate("IP address"))
  43. udp_peers:option(Value, "port", translate("Port")).datatype = "portrange"
  44. udp_peers:option(Value, "public_key", translate("Public key"))
  45. udp_peers:option(Value, "password", translate("Password"))
  46. -- Ethernet Peers
  47. eth_peers = m:section(TypedSection, "eth_peer", translate("Outgoing Ethernet Peers"),
  48. translate("For peering via local Ethernet networks, the peer handed you their Public Key and MAC address along with a password."))
  49. eth_peers.anonymous = true
  50. eth_peers.addremove = true
  51. eth_peers.template = "cbi/tblsection"
  52. eth_interface = eth_peers:option(Value, "interface", translate("Ethernet interface"))
  53. local index = 1
  54. for i,section in pairs(cursor:get_all("cjdns")) do
  55. if section[".type"] == "eth_interface" then
  56. eth_interface:value(index, section.bind)
  57. end
  58. end
  59. eth_interface.default = 1
  60. eth_peers:option(Value, "address", translate("MAC address")).datatype = "macaddr"
  61. eth_peers:option(Value, "public_key", translate("Public key"))
  62. eth_peers:option(Value, "password", translate("Password"))
  63. return m