mirror of
https://github.com/Ysurac/openmptcprouter-feeds.git
synced 2025-03-09 15:40:03 +00:00
fix zero
This commit is contained in:
parent
3c98571845
commit
1a12825c09
24 changed files with 327 additions and 333 deletions
2
luci-app-zerotier-master/.gitattributes
vendored
Normal file
2
luci-app-zerotier-master/.gitattributes
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
# Auto detect text files and perform LF normalization
|
||||||
|
* text=auto
|
2
luci-app-zerotier-master/.gitignore
vendored
Normal file
2
luci-app-zerotier-master/.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
|
||||||
|
*.bak
|
6
luci-app-zerotier/Makefile → luci-app-zerotier-master/Makefile
Executable file → Normal file
6
luci-app-zerotier/Makefile → luci-app-zerotier-master/Makefile
Executable file → Normal file
|
@ -9,11 +9,11 @@ include $(TOPDIR)/rules.mk
|
||||||
LUCI_TITLE:=LuCI for Zerotier
|
LUCI_TITLE:=LuCI for Zerotier
|
||||||
LUCI_DEPENDS:=+zerotier
|
LUCI_DEPENDS:=+zerotier
|
||||||
LUCI_PKGARCH:=all
|
LUCI_PKGARCH:=all
|
||||||
|
|
||||||
PKG_NAME:=luci-app-zerotier
|
|
||||||
PKG_VERSION:=1.0
|
PKG_VERSION:=1.0
|
||||||
PKG_RELEASE:=21
|
PKG_RELEASE:=17
|
||||||
|
|
||||||
include $(TOPDIR)/feeds/luci/luci.mk
|
include $(TOPDIR)/feeds/luci/luci.mk
|
||||||
|
|
||||||
# call BuildPackage - OpenWrt buildroot signature
|
# call BuildPackage - OpenWrt buildroot signature
|
||||||
|
|
||||||
|
|
4
luci-app-zerotier-master/README.md
Normal file
4
luci-app-zerotier-master/README.md
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
# luci-app-zerotier
|
||||||
|
|
||||||
|
你不在乎网络安全,可我在乎<br>
|
||||||
|
与lean原版相比使用了op自带的防火墙,并增添了流量权限控制
|
24
luci-app-zerotier-master/luasrc/controller/zerotier.lua
Normal file
24
luci-app-zerotier-master/luasrc/controller/zerotier.lua
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
module("luci.controller.zerotier",package.seeall)
|
||||||
|
|
||||||
|
function index()
|
||||||
|
if not nixio.fs.access("/etc/config/zerotier")then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
entry({"admin","vpn"}, firstchild(), "VPN", 45).dependent = false
|
||||||
|
|
||||||
|
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", "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)
|
||||||
|
end
|
15
luci-app-zerotier-master/luasrc/model/cbi/zerotier/info.lua
Normal file
15
luci-app-zerotier-master/luasrc/model/cbi/zerotier/info.lua
Normal 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
|
|
@ -0,0 +1,25 @@
|
||||||
|
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/db813db7e875c257e42c41ab8091c3df1e9300a5/service/README.md" target="_blank">https://github.com/zerotier/ZeroTierOne/blob/db813db7e875c257e42c41ab8091c3df1e9300a5/service/README.md</a>'
|
||||||
|
return m
|
|
@ -0,0 +1,34 @@
|
||||||
|
|
||||||
|
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 = 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
|
|
@ -0,0 +1,22 @@
|
||||||
|
<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>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
//]]>
|
||||||
|
</script>
|
||||||
|
<style>.mar-10 {margin-left: 50px; margin-right: 10px;}</style>
|
||||||
|
<fieldset class="cbi-section">
|
||||||
|
<p id="zerotier_status">
|
||||||
|
<em><%:Collecting data...%></em>
|
||||||
|
</p>
|
||||||
|
</fieldset>
|
28
luci-app-zerotier-master/po/zh-cn/zerotier.po
Normal file
28
luci-app-zerotier-master/po/zh-cn/zerotier.po
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
"MIME-Version: 1.0\n"
|
||||||
|
"Content-Type: text/plain; charset=UTF-8\n"
|
||||||
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
|
"X-Generator: Gtranslator 2.91.7\n"
|
||||||
|
"Plural-Forms: nplurals=1; plural=0;\n"
|
||||||
|
|
||||||
|
msgid "Zerotier is an open source, cross-platform and easy to use virtual LAN"
|
||||||
|
msgstr "Zerotier是一个开源,跨平台,而且适合内网穿透互联的傻瓜配置虚拟 VPN LAN"
|
||||||
|
|
||||||
|
msgid "Auto NAT Clients"
|
||||||
|
msgstr "自动允许客户端NAT"
|
||||||
|
|
||||||
|
msgid "Allow zerotier clients access your LAN network"
|
||||||
|
msgstr "允许Zerotier的拨入客户端访问路由器LAN资源(需要在 Zerotier管理页面设定到LAN网段的路由表)"
|
||||||
|
|
||||||
|
msgid "Create or manage your zerotier network, and auth clients who could access"
|
||||||
|
msgstr "点击跳转到Zerotier官网管理平台,新建或者管理网络,并允许客户端接入访问你私人网路(新接入的节点默认不允许访问)"
|
||||||
|
|
||||||
|
msgid "Interface Info"
|
||||||
|
msgstr "接口信息"
|
||||||
|
|
||||||
|
msgid "Zerotier access control"
|
||||||
|
msgstr "Zerotier 准入控制"
|
||||||
|
|
||||||
|
msgid "Manual Config"
|
||||||
|
msgstr "手动设置"
|
5
luci-app-zerotier-master/root/etc/config/zero/local.conf
Normal file
5
luci-app-zerotier-master/root/etc/config/zero/local.conf
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"settings": {
|
||||||
|
"multipathMode": 2
|
||||||
|
}
|
||||||
|
}
|
163
luci-app-zerotier-master/root/etc/init.d/zerotier
Executable file
163
luci-app-zerotier-master/root/etc/init.d/zerotier
Executable file
|
@ -0,0 +1,163 @@
|
||||||
|
#!/bin/sh /etc/rc.common
|
||||||
|
|
||||||
|
START=90
|
||||||
|
|
||||||
|
USE_PROCD=1
|
||||||
|
|
||||||
|
PROG=/usr/bin/zerotier-one
|
||||||
|
CONFIG_PATH=/var/lib/zerotier-one
|
||||||
|
|
||||||
|
section_enabled() {
|
||||||
|
config_get_bool enabled "$1" 'enabled' 0
|
||||||
|
[ $enabled -gt 0 ]
|
||||||
|
}
|
||||||
|
service_triggers() {
|
||||||
|
procd_add_reload_trigger zerotier
|
||||||
|
}
|
||||||
|
start_instance() {
|
||||||
|
local cfg="$1"
|
||||||
|
local port secret config_path
|
||||||
|
local ARGS=""
|
||||||
|
|
||||||
|
if ! section_enabled "$cfg"; then
|
||||||
|
echo "disabled in config"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
[ -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'
|
||||||
|
|
||||||
|
# Remove existing link or folder
|
||||||
|
rm -rf $CONFIG_PATH
|
||||||
|
|
||||||
|
# Create link from CONFIG_PATH to config_path
|
||||||
|
if [ -n "$config_path" -a "$config_path" != $CONFIG_PATH ]; then
|
||||||
|
if [ ! -d "$config_path" ]; then
|
||||||
|
echo "ZeroTier config_path does not exist: $config_path"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
ln -s $config_path $CONFIG_PATH
|
||||||
|
fi
|
||||||
|
|
||||||
|
mkdir -p $CONFIG_PATH/networks.d
|
||||||
|
|
||||||
|
if [ -n "$port" ]; then
|
||||||
|
ARGS="$ARGS -p$port"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$secret" = "generate" ]; then
|
||||||
|
echo "Generate secret - please wait..."
|
||||||
|
local sf="/tmp/zt.$cfg.secret"
|
||||||
|
|
||||||
|
zerotier-idtool generate "$sf" > /dev/null
|
||||||
|
[ $? -ne 0 ] && return 1
|
||||||
|
|
||||||
|
secret="$(cat $sf)"
|
||||||
|
rm "$sf"
|
||||||
|
|
||||||
|
uci set zerotier.$cfg.secret="$secret"
|
||||||
|
uci commit zerotier
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$secret" ]; then
|
||||||
|
echo "$secret" > $CONFIG_PATH/identity.secret
|
||||||
|
# make sure there is not previous identity.public
|
||||||
|
rm -f $CONFIG_PATH/identity.public
|
||||||
|
fi
|
||||||
|
|
||||||
|
add_join() {
|
||||||
|
# an (empty) config file will cause ZT to join a network
|
||||||
|
touch $CONFIG_PATH/networks.d/$1.conf
|
||||||
|
}
|
||||||
|
|
||||||
|
config_list_foreach $cfg 'join' add_join
|
||||||
|
|
||||||
|
procd_open_instance
|
||||||
|
procd_set_param command $PROG $ARGS $CONFIG_PATH
|
||||||
|
procd_set_param stderr 1
|
||||||
|
procd_close_instance
|
||||||
|
(
|
||||||
|
[ -f "/var/run/zerotier.wait.pid" ] && return
|
||||||
|
touch /var/run/zerotier.wait.pid
|
||||||
|
while [ "$(ifconfig | grep zt | awk '{print $1}')" = "" ]
|
||||||
|
do
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
zt0=$(ifconfig | grep zt | awk '{print $1}')
|
||||||
|
echo "zt interface $zt0 is started!"
|
||||||
|
if [ -z "$(uci get network.zerotier)" ]; then
|
||||||
|
uci set network.zerotier=interface
|
||||||
|
uci set network.zerotier.proto='static'
|
||||||
|
fi
|
||||||
|
config_get nat $cfg 'nat'
|
||||||
|
if [ "$nat" == "1" ]; then
|
||||||
|
if [ -z "$(uci get firewall.ztzone)" ]; then
|
||||||
|
uci set firewall.ztzone=zone
|
||||||
|
uci set firewall.ztzone.input='ACCEPT'
|
||||||
|
uci set firewall.ztzone.output='ACCEPT'
|
||||||
|
uci set firewall.ztzone.forward='REJECT'
|
||||||
|
uci set firewall.ztzone.masq='1'
|
||||||
|
uci set firewall.ztzone.name='zerotier'
|
||||||
|
uci set firewall.ztzone.network='zerotier'
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
uci delete firewall.ztzone
|
||||||
|
fi
|
||||||
|
config_get access $cfg 'access'
|
||||||
|
if [ "${access//ztfwlan/}" != "$access" ]; then
|
||||||
|
uci set firewall.ztfwlan=forwarding
|
||||||
|
uci set firewall.ztfwlan.dest='lan'
|
||||||
|
uci set firewall.ztfwlan.src='zerotier'
|
||||||
|
else
|
||||||
|
uci delete firewall.ztfwlan
|
||||||
|
fi
|
||||||
|
if [ "${access//ztfwwan/}" != "$access" ]; then
|
||||||
|
uci set firewall.ztfwwan=forwarding
|
||||||
|
uci set firewall.ztfwwan.dest='wan'
|
||||||
|
uci set firewall.ztfwwan.src='zerotier'
|
||||||
|
else
|
||||||
|
uci delete firewall.ztfwwan
|
||||||
|
fi
|
||||||
|
if [ "${access//lanfwzt/}" != "$access" ]; then
|
||||||
|
uci set firewall.lanfwzt=forwarding
|
||||||
|
uci set firewall.lanfwzt.dest='zerotier'
|
||||||
|
uci set firewall.lanfwzt.src='lan'
|
||||||
|
else
|
||||||
|
uci delete firewall.lanfwzt
|
||||||
|
fi
|
||||||
|
if [ "${access//wanfwzt/}" != "$access" ]; then
|
||||||
|
uci set firewall.wanfwzt=forwarding
|
||||||
|
uci set firewall.wanfwzt.dest='zerotier'
|
||||||
|
uci set firewall.wanfwzt.src='wan'
|
||||||
|
else
|
||||||
|
uci delete firewall.wanfwzt
|
||||||
|
fi
|
||||||
|
uci set network.zerotier.ifname="$zt0"
|
||||||
|
[ -n "$(uci changes network)" ] && uci commit network && /etc/init.d/network reload
|
||||||
|
[ -n "$(uci changes firewall)" ] && uci commit firewall && /etc/init.d/firewall reload
|
||||||
|
rm /var/run/zerotier.wait.pid
|
||||||
|
) &
|
||||||
|
}
|
||||||
|
|
||||||
|
start_service() {
|
||||||
|
config_load 'zerotier'
|
||||||
|
config_foreach start_instance 'zerotier'
|
||||||
|
}
|
||||||
|
|
||||||
|
stop_instance() {
|
||||||
|
rm -f /tmp/zero.log
|
||||||
|
local cfg="$1"
|
||||||
|
|
||||||
|
# Remove existing link or folder
|
||||||
|
rm -rf $CONFIG_PATH
|
||||||
|
}
|
||||||
|
|
||||||
|
stop_service() {
|
||||||
|
config_load 'zerotier'
|
||||||
|
config_foreach stop_instance 'zerotier'
|
||||||
|
}
|
||||||
|
|
|
@ -5,13 +5,6 @@ uci -q batch <<-EOF >/dev/null
|
||||||
add ucitrack zerotier
|
add ucitrack zerotier
|
||||||
set ucitrack.@zerotier[-1].init=zerotier
|
set ucitrack.@zerotier[-1].init=zerotier
|
||||||
commit ucitrack
|
commit ucitrack
|
||||||
|
|
||||||
delete firewall.zerotier
|
|
||||||
set firewall.zerotier=include
|
|
||||||
set firewall.zerotier.type=script
|
|
||||||
set firewall.zerotier.path=/etc/zerotier.start
|
|
||||||
set firewall.zerotier.reload=1
|
|
||||||
commit firewall
|
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
rm -f /tmp/luci-indexcache
|
rm -f /tmp/luci-indexcache
|
0
luci-app-zerotier/root/etc/zerotier/zerotier.log → luci-app-zerotier-master/root/etc/zerotier/zerotier.log
Executable file → Normal file
0
luci-app-zerotier/root/etc/zerotier/zerotier.log → luci-app-zerotier-master/root/etc/zerotier/zerotier.log
Executable file → Normal file
|
@ -1,24 +0,0 @@
|
||||||
module("luci.controller.zerotier", package.seeall)
|
|
||||||
|
|
||||||
function index()
|
|
||||||
if not nixio.fs.access("/etc/config/zerotier") then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
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", "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)
|
|
||||||
end
|
|
|
@ -1,15 +0,0 @@
|
||||||
local fs = require "nixio.fs"
|
|
||||||
local conffile = "/tmp/zero.info"
|
|
||||||
|
|
||||||
f = SimpleForm("logview")
|
|
||||||
|
|
||||||
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 ""
|
|
||||||
end
|
|
||||||
t.readonly = "readonly"
|
|
||||||
|
|
||||||
return f
|
|
|
@ -1,26 +0,0 @@
|
||||||
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
|
|
|
@ -1,37 +0,0 @@
|
||||||
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"
|
|
||||||
|
|
||||||
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.description = translate("Allow zerotier clients access your LAN network")
|
|
||||||
e.default = 0
|
|
||||||
e.rmempty = false
|
|
||||||
|
|
||||||
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
|
|
|
@ -1,29 +0,0 @@
|
||||||
<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>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
//]]>
|
|
||||||
</script>
|
|
||||||
<style>
|
|
||||||
.mar-10 {
|
|
||||||
margin-left: 50px;
|
|
||||||
margin-right: 10px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
<fieldset class="cbi-section">
|
|
||||||
<p id="zerotier_status">
|
|
||||||
<em>
|
|
||||||
<%:Collecting data...%>
|
|
||||||
</em>
|
|
||||||
</p>
|
|
||||||
</fieldset>
|
|
|
@ -1,35 +0,0 @@
|
||||||
msgid "Zerotier is an open source, cross-platform and easy to use virtual LAN"
|
|
||||||
msgstr "Zerotier 是一个开源,跨平台,而且适合内网穿透互联的傻瓜配置虚拟 VPN LAN"
|
|
||||||
|
|
||||||
msgid "Auto NAT Clients"
|
|
||||||
msgstr "自动允许客户端 NAT"
|
|
||||||
|
|
||||||
msgid "Allow zerotier clients access your LAN network"
|
|
||||||
msgstr "允许 Zerotier 的拨入客户端访问路由器 LAN 资源(需要在 Zerotier 管理页面设定到 LAN 网段的路由表)"
|
|
||||||
|
|
||||||
msgid "Create or manage your zerotier network, and auth clients who could access"
|
|
||||||
msgstr "点击跳转到 Zerotier 官网管理平台,新建或者管理网络,并允许客户端接入访问你私人网路(新接入的节点默认不允许访问)"
|
|
||||||
|
|
||||||
msgid "Base Setting"
|
|
||||||
msgstr "基本设置"
|
|
||||||
|
|
||||||
msgid "Interface Info"
|
|
||||||
msgstr "接口信息"
|
|
||||||
|
|
||||||
msgid "Zerotier Access Control"
|
|
||||||
msgstr "Zerotier 准入控制"
|
|
||||||
|
|
||||||
msgid "LAN Access Zerotier"
|
|
||||||
msgstr "LAN 可接入 Zerotier"
|
|
||||||
|
|
||||||
msgid "WAN Access Zerotier"
|
|
||||||
msgstr "WAN 可接入 Zerotier"
|
|
||||||
|
|
||||||
msgid "Remote Access WAN"
|
|
||||||
msgstr "外部访问可接入 WAN"
|
|
||||||
|
|
||||||
msgid "Remote Access LAN"
|
|
||||||
msgstr "外部访问可接入 LAN"
|
|
||||||
|
|
||||||
msgid "Manual Config"
|
|
||||||
msgstr "手动设置"
|
|
|
@ -1 +0,0 @@
|
||||||
zh-cn
|
|
|
@ -1,113 +0,0 @@
|
||||||
#!/bin/sh /etc/rc.common
|
|
||||||
|
|
||||||
START=99
|
|
||||||
|
|
||||||
USE_PROCD=1
|
|
||||||
|
|
||||||
PROG=/usr/bin/zerotier-one
|
|
||||||
CONFIG_PATH=/var/lib/zerotier-one
|
|
||||||
|
|
||||||
service_triggers() {
|
|
||||||
procd_add_reload_trigger "zerotier"
|
|
||||||
procd_add_interface_trigger "interface.*.up" wan /etc/init.d/zerotier restart
|
|
||||||
}
|
|
||||||
|
|
||||||
section_enabled() {
|
|
||||||
config_get_bool enabled "$1" 'enabled' 0
|
|
||||||
[ $enabled -gt 0 ]
|
|
||||||
}
|
|
||||||
|
|
||||||
start_instance() {
|
|
||||||
local cfg="$1"
|
|
||||||
local port secret config_path
|
|
||||||
local ARGS=""
|
|
||||||
|
|
||||||
if ! section_enabled "$cfg"; then
|
|
||||||
echo "disabled in config"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
[ -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'
|
|
||||||
|
|
||||||
# Remove existing link or folder
|
|
||||||
rm -rf $CONFIG_PATH
|
|
||||||
|
|
||||||
# Create link from CONFIG_PATH to config_path
|
|
||||||
if [ -n "$config_path" -a "$config_path" != $CONFIG_PATH ]; then
|
|
||||||
if [ ! -d "$config_path" ]; then
|
|
||||||
echo "ZeroTier config_path does not exist: $config_path"
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
ln -s $config_path $CONFIG_PATH
|
|
||||||
fi
|
|
||||||
|
|
||||||
mkdir -p $CONFIG_PATH/networks.d
|
|
||||||
|
|
||||||
if [ -n "$port" ]; then
|
|
||||||
ARGS="$ARGS -p$port"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$secret" = "generate" ]; then
|
|
||||||
echo "Generate secret - please wait..."
|
|
||||||
local sf="/tmp/zt.$cfg.secret"
|
|
||||||
|
|
||||||
zerotier-idtool generate "$sf" > /dev/null
|
|
||||||
[ $? -ne 0 ] && return 1
|
|
||||||
|
|
||||||
secret="$(cat $sf)"
|
|
||||||
rm "$sf"
|
|
||||||
|
|
||||||
uci set zerotier.$cfg.secret="$secret"
|
|
||||||
uci commit zerotier
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "$secret" ]; then
|
|
||||||
echo "$secret" > $CONFIG_PATH/identity.secret
|
|
||||||
# make sure there is not previous identity.public
|
|
||||||
rm -f $CONFIG_PATH/identity.public
|
|
||||||
fi
|
|
||||||
|
|
||||||
add_join() {
|
|
||||||
# an (empty) config file will cause ZT to join a network
|
|
||||||
touch $CONFIG_PATH/networks.d/$1.conf
|
|
||||||
}
|
|
||||||
|
|
||||||
config_list_foreach $cfg 'join' add_join
|
|
||||||
|
|
||||||
procd_open_instance
|
|
||||||
procd_set_param command $PROG $ARGS $CONFIG_PATH
|
|
||||||
procd_set_param stderr 1
|
|
||||||
procd_close_instance
|
|
||||||
}
|
|
||||||
|
|
||||||
start_service() {
|
|
||||||
config_load 'zerotier'
|
|
||||||
config_foreach start_instance 'zerotier'
|
|
||||||
touch /tmp/zero.log && /etc/zerotier.start > /tmp/zero.log 2>&1 &
|
|
||||||
}
|
|
||||||
|
|
||||||
stop_instance() {
|
|
||||||
rm -f /tmp/zero.log
|
|
||||||
local cfg="$1"
|
|
||||||
|
|
||||||
/etc/zerotier.stop > /tmp/zero.log 2>&1 &
|
|
||||||
|
|
||||||
# Remove existing link or folder
|
|
||||||
rm -f $CONFIG_PATH/networks.d/*.conf
|
|
||||||
rm -rf $CONFIG_PATH
|
|
||||||
}
|
|
||||||
|
|
||||||
stop_service() {
|
|
||||||
config_load 'zerotier'
|
|
||||||
config_foreach stop_instance 'zerotier'
|
|
||||||
}
|
|
||||||
|
|
||||||
reload_service() {
|
|
||||||
stop
|
|
||||||
start
|
|
||||||
}
|
|
|
@ -1,28 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
zero_enable="$(uci get zerotier.sample_config.enabled)"
|
|
||||||
|
|
||||||
[ "${zero_enable}" -ne "1" ] && exit 0
|
|
||||||
|
|
||||||
[ -f "/tmp/zero.log" ] && {
|
|
||||||
while [ "$(ifconfig | grep 'zt' | awk '{print $1}')" = "" ]
|
|
||||||
do
|
|
||||||
sleep 1
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
nat_enable="$(uci get zerotier.sample_config.nat)"
|
|
||||||
zt0="$(ifconfig | grep 'zt' | awk '{print $1}')"
|
|
||||||
echo "${zt0}" > "/tmp/zt.nif"
|
|
||||||
|
|
||||||
[ "${nat_enable}" -eq "1" ] && {
|
|
||||||
for i in ${zt0}
|
|
||||||
do
|
|
||||||
ip_segment=""
|
|
||||||
iptables -I FORWARD -i "$i" -j ACCEPT
|
|
||||||
iptables -I FORWARD -o "$i" -j ACCEPT
|
|
||||||
iptables -t nat -I POSTROUTING -o "$i" -j MASQUERADE
|
|
||||||
ip_segment="$(ip route | grep "dev $i proto kernel" | awk '{print $1}')"
|
|
||||||
iptables -t nat -I POSTROUTING -s "${ip_segment}" -j MASQUERADE
|
|
||||||
done
|
|
||||||
}
|
|
|
@ -1,15 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
zt0="$(ifconfig | grep 'zt' | awk '{print $1}')"
|
|
||||||
[ -z "${zt0}" ] && zt0="$(cat "/tmp/zt.nif")"
|
|
||||||
|
|
||||||
for i in ${zt0}
|
|
||||||
do
|
|
||||||
ip_segment=""
|
|
||||||
iptables -D FORWARD -i "$i" -j ACCEPT 2>/dev/null
|
|
||||||
iptables -D FORWARD -o "$i" -j ACCEPT 2>/dev/null
|
|
||||||
iptables -t nat -D POSTROUTING -o "$i" -j MASQUERADE 2>/dev/null
|
|
||||||
ip_segment="$(ip route | grep "dev $i proto" | awk '{print $1}')"
|
|
||||||
iptables -t nat -D POSTROUTING -s "${ip_segment}" -j MASQUERADE 2>/dev/null
|
|
||||||
echo "zt interface $i is stopped!"
|
|
||||||
done
|
|
Loading…
Add table
Add a link
Reference in a new issue