luci app zerotier: path bug fix

This commit is contained in:
coolsnowwolf 2019-05-16 22:57:57 +08:00
parent 0935c47a8e
commit 2915c44a11
6 changed files with 53 additions and 55 deletions

View File

@ -10,7 +10,7 @@ LUCI_TITLE:=LuCI for Zerotier
LUCI_DEPENDS:=+zerotier
LUCI_PKGARCH:=all
PKG_VERSION:=1.0
PKG_RELEASE:=13
PKG_RELEASE:=15
include $(TOPDIR)/feeds/luci/luci.mk

View File

@ -6,8 +6,13 @@ return
end
entry({"admin","vpn"}, firstchild(), "VPN", 45).dependent = false
entry({"admin","vpn","zerotier"},cbi("zerotier"),_("ZeroTier"),90).dependent=true
entry({"admin","vpn","zerotier","status"},call("act_status")).leaf=true
entry({"admin", "vpn", "zerotier"},firstchild(), _("ZeroTier")).dependent = false
entry({"admin", "vpn", "zerotier", "general"},cbi("zerotier/settings"), _("Base Setting"), 1)
entry({"admin", "vpn", "zerotier", "log"},form("zerotier/info"), _("Interface Info"), 2)
entry({"admin","vpn","zerotier","status"},call("act_status"))
end
function act_status()

View File

@ -1,50 +0,0 @@
local e=require"nixio.fs"
local e=luci.http
local o=require"luci.model.network".init()
local a,t,e,b
a=Map("zerotier",translate("ZeroTier"),translate("Zerotier is an open source, cross-platform and easy to use virtual LAN"))
a:section(SimpleSection).template = "zerotier/zerotier_status"
t=a:section(NamedSection,"sample_config","zerotier")
t.anonymous=true
t.addremove=false
t:tab("basic", translate("Base Setting"))
e=t:taboption("basic", Flag,"enabled",translate("Enable"))
e.default=0
e.rmempty=false
e=t:taboption("basic", DynamicList,"join",translate('ZeroTier Network ID'))
e.password=true
e.rmempty=false
e=t:taboption("basic", Flag,"nat",translate("Auto NAT Clients"))
e.default=0
e.rmempty=false
e.description = translate("Allow zerotier clients access your LAN network")
e=t:taboption("basic", DummyValue,"opennewwindow" ,
translate("<input type=\"button\" class=\"cbi-button cbi-button-apply\" value=\"Zerotier.com\" onclick=\"window.open('https://my.zerotier.com/network')\" />"))
e.description = translate("Create or manage your zerotier network, and auth clients who could access")
local dog = "/tmp/zero.info"
t:tab("watchdog", translate("Interface Info"))
log = t:taboption("watchdog", TextValue, "sylogtext")
log.template = "cbi/tvalue"
log.rows = 8
log.wrap = "off"
log.readonly="readonly"
function log.cfgvalue(self, section)
luci.sys.exec("ifconfig $(ifconfig | grep zt | awk '{print $1}') > /tmp/zero.info")
return nixio.fs.readfile(dog) or ""
end
function log.write(self, section, value)
value = value:gsub("\r\n?", "\n")
nixio.fs.writefile(dog, value)
end
return a

View File

@ -0,0 +1,15 @@
local fs = require "nixio.fs"
local conffile = "/tmp/zero.info"
f = SimpleForm("logview")
t = f:field(TextValue, "conf")
t.rmempty = true
t.rows = 15
function t.cfgvalue()
luci.sys.exec("ifconfig $(ifconfig | grep zt | awk '{print $1}') > /tmp/zero.info")
return fs.readfile(conffile) or ""
end
t.readonly="readonly"
return f

View File

@ -0,0 +1,26 @@
a=Map("zerotier",translate("ZeroTier"),translate("Zerotier is an open source, cross-platform and easy to use virtual LAN"))
a:section(SimpleSection).template = "zerotier/zerotier_status"
t=a:section(NamedSection,"sample_config","zerotier")
t.anonymous=true
t.addremove=false
e=t:option(Flag,"enabled",translate("Enable"))
e.default=0
e.rmempty=false
e=t:option(DynamicList,"join",translate('ZeroTier Network ID'))
e.password=true
e.rmempty=false
e=t:option(Flag,"nat",translate("Auto NAT Clients"))
e.default=0
e.rmempty=false
e.description = translate("Allow zerotier clients access your LAN network")
e=t:option(DummyValue,"opennewwindow" ,
translate("<input type=\"button\" class=\"cbi-button cbi-button-apply\" value=\"Zerotier.com\" onclick=\"window.open('https://my.zerotier.com/network')\" />"))
e.description = translate("Create or manage your zerotier network, and auth clients who could access")
return a

View File

@ -21,8 +21,10 @@ start_instance() {
echo "disabled in config"
return 1
fi
config_get config_path $cfg 'config_path'
[ -d /etc/config/zero ] || mkdir -p /etc/config/zero
config_path=/etc/config/zero
config_get_bool port $cfg 'port'
config_get secret $cfg 'secret'