0100-mesh-vpn.lua 946 B

123456789101112131415161718192021222324252627282930313233
  1. local uci = require("simple-uci").cursor()
  2. local meshvpn_enabled = uci:get_bool("fastd", "mesh_vpn", "enabled")
  3. if not meshvpn_enabled then
  4. return nil
  5. else
  6. local i18n = require "luci.i18n"
  7. local util = require "luci.util"
  8. local gluon_luci = require 'gluon.luci'
  9. local site = require 'gluon.site_config'
  10. local sysconfig = require 'gluon.sysconfig'
  11. local pretty_hostname = require 'pretty_hostname'
  12. local pubkey = util.trim(util.exec("/etc/init.d/fastd show_key " .. "mesh_vpn"))
  13. local hostname = pretty_hostname.get(uci)
  14. local contact = uci:get_first("gluon-node-info", "owner", "contact")
  15. local msg = i18n.translate('gluon-config-mode:pubkey')
  16. return function ()
  17. luci.template.render_string(msg, {
  18. pubkey = pubkey,
  19. hostname = hostname,
  20. site = site,
  21. sysconfig = sysconfig,
  22. contact = contact,
  23. escape = gluon_luci.escape,
  24. urlescape = gluon_luci.urlescape,
  25. })
  26. end
  27. end