1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter-feeds.git synced 2025-03-09 15:40:03 +00:00
This commit is contained in:
suyuan 2023-01-18 21:21:55 +08:00
parent 6b7f0b4dba
commit fd8b7384d5
104 changed files with 13356 additions and 31 deletions

View file

@ -1,22 +1,24 @@
module("luci.controller.zerotier", package.seeall)
function index()
if not nixio.fs.access("/etc/config/zerotier") then
return
end
if not nixio.fs.access("/etc/config/zerotier") then
return
end
entry({"admin", "vpn"}, firstchild(), "VPN", 45).dependent = false
entry({"admin", "vpn"}, firstchild(), "VPN", 45).dependent = false
entry({"admin", "vpn", "zerotier"}, alias("admin", "vpn", "zerotier", "general"), _("ZeroTier"), 99)
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"}, alias("admin", "vpn", "zerotier", "general"), _("ZeroTier"), 99)
entry({"admin", "vpn", "zerotier", "status"}, call("act_status"))
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", "manual"}, cbi("zerotier/manual"), _("Manual Config"), 3)
entry({"admin", "vpn", "zerotier", "status"}, call("act_status"))
end
function act_status()
local e = {}
e.running = luci.sys.call("pgrep /usr/bin/zerotier-one >/dev/null") == 0
luci.http.prepare_content("application/json")
luci.http.write_json(e)
local e = {}
e.running = luci.sys.call("pgrep /usr/bin/zerotier-one >/dev/null") == 0
luci.http.prepare_content("application/json")
luci.http.write_json(e)
end

View file

@ -7,8 +7,8 @@ t = f:field(TextValue, "conf")
t.rmempty = true
t.rows = 19
function t.cfgvalue()
luci.sys.exec("for i in $(ifconfig | grep 'zt' | awk '{print $1}'); do ifconfig $i; done > /tmp/zero.info")
return fs.readfile(conffile) or ""
luci.sys.exec("for i in $(ifconfig | grep 'zt' | awk '{print $1}'); do ifconfig $i; done > /tmp/zero.info")
return fs.readfile(conffile) or ""
end
t.readonly = "readonly"

View file

@ -0,0 +1,26 @@
local m, s, o
local fs = require "nixio.fs"
local jsonc = require "luci.jsonc" or nil
m = Map("zerotier")
s = m:section(NamedSection, "sample_config", "zerotier")
s.anonymous = true
s.addremove = false
o = s:option(TextValue, "manualconfig")
o.rows = 20
o.wrap = "soft"
o.rmempty = true
o.cfgvalue = function(self, section)
return fs.readfile("/etc/config/zero/local.conf")
end
o.write = function(self, section, value)
fs.writefile("/etc/config/zero/local.conf", value:gsub("\r\n", "\n"))
end
o.validate = function(self, value)
if jsonc == nil or jsonc.parse(value) ~= nil then
return value
end
return nil
end
o.description =
'<a href="https://www.zerotier.com/manual/" target="_blank">https://www.zerotier.com/manual/</a><br><a href="https://github.com/zerotier/ZeroTierOne/blob/dev/service/README.md" target="_blank">https://github.com/zerotier/ZeroTierOne/blob/dev/service/README.md</a>'
return m

View file

@ -2,7 +2,7 @@ a = Map("zerotier")
a.title = translate("ZeroTier")
a.description = translate("Zerotier is an open source, cross-platform and easy to use virtual LAN")
a:section(SimpleSection).template = "zerotier/zerotier_status"
a:section(SimpleSection).template = "zerotier/zerotier_status"
t = a:section(NamedSection, "sample_config", "zerotier")
t.anonymous = true
@ -21,7 +21,17 @@ e.description = translate("Allow zerotier clients access your LAN network")
e.default = 0
e.rmempty = false
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 = t:option(MultiValue, "access", translate("Zerotier Access Control"))
e.default = "lanfwzt ztfwwan ztfwlan"
e.rmempty = false
e:value("lanfwzt", translate("LAN Access Zerotier"))
e:value("wanfwzt", translate("WAN Access Zerotier"))
e:value("ztfwwan", translate("Remote Access WAN"))
e:value("ztfwlan", translate("Remote Access LAN"))
e.widget = "checkbox"
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

@ -1,22 +1,29 @@
<script type="text/javascript">//<![CDATA[
XHR.poll(3, '<%=url([[admin]], [[vpn]], [[zerotier]], [[status]])%>', null,
function(x, data) {
var tb = document.getElementById('zerotier_status');
if (data && tb) {
if (data.running) {
var links = '<em><b><font color=green>Zerotier <%:RUNNING%></font></b></em>';
tb.innerHTML = links;
} else {
tb.innerHTML = '<em><b><font color=red>Zerotier <%:NOT RUNNING%></font></b></em>';
XHR.poll(3, '<%=url([[admin]], [[vpn]], [[zerotier]], [[status]])%>', null,
function (x, data) {
var tb = document.getElementById('zerotier_status');
if (data && tb) {
if (data.running) {
var links = '<em><b><font color=green>Zerotier <%:RUNNING%></font></b></em>';
tb.innerHTML = links;
} else {
tb.innerHTML = '<em><b><font color=red>Zerotier <%:NOT RUNNING%></font></b></em>';
}
}
}
}
);
);
//]]>
</script>
<style>.mar-10 {margin-left: 50px; margin-right: 10px;}</style>
<style>
.mar-10 {
margin-left: 50px;
margin-right: 10px;
}
</style>
<fieldset class="cbi-section">
<p id="zerotier_status">
<em><%:Collecting data...%></em>
<em>
<%:Collecting data...%>
</em>
</p>
</fieldset>
</fieldset>