0100-mesh-vpn.lua 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. local uci = luci.model.uci.cursor()
  2. local meshvpn_enabled = uci:get("fastd", "mesh_vpn", "enabled", "0")
  3. if meshvpn_enabled ~= "1" then
  4. return nil
  5. else
  6. local i18n = require "luci.i18n"
  7. local util = require "luci.util"
  8. local site = require 'gluon.site_config'
  9. local sysconfig = require 'gluon.sysconfig'
  10. local pubkey = util.trim(util.exec("/etc/init.d/fastd show_key " .. "mesh_vpn"))
  11. local hostname = uci:get_first("system", "system", "hostname")
  12. local contact = uci:get_first("gluon-node-info", "owner", "contact")
  13. local msg = [[<p>]] .. i18n.translate('gluon-config-mode:pubkey') .. [[</p>
  14. <div class="the-key">
  15. # <%= hostname %>
  16. <br/>
  17. <%= pubkey %>
  18. </div>]]
  19. return function ()
  20. luci.template.render_string(msg, { pubkey=pubkey
  21. , hostname=hostname
  22. , site=site
  23. , sysconfig=sysconfig
  24. , contact=contact
  25. })
  26. end
  27. end