mirror of
https://github.com/hanwckf/immortalwrt-mt798x.git
synced 2025-01-10 11:09:57 +08:00
parent
7e6bf9da10
commit
6829f246e1
@ -10,7 +10,7 @@ LUCI_TITLE:=LuCI for Zerotier
|
||||
LUCI_DEPENDS:=+zerotier
|
||||
LUCI_PKGARCH:=all
|
||||
PKG_VERSION:=1.0
|
||||
PKG_RELEASE:=18
|
||||
PKG_RELEASE:=19
|
||||
|
||||
include $(TOPDIR)/feeds/luci/luci.mk
|
||||
|
||||
|
@ -7,9 +7,9 @@ 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")
|
||||
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
|
||||
return f
|
||||
|
@ -1,29 +1,35 @@
|
||||
#!/bin/sh
|
||||
|
||||
zero_enable=$(uci get zerotier.sample_config.enabled)
|
||||
zero_enable="$(uci get zerotier.sample_config.enabled)"
|
||||
|
||||
if [ $zero_enable -eq 1 ]; then
|
||||
[ "${zero_enable}" -ne "1" ] && exit 0
|
||||
|
||||
if [ -f /tmp/zero.log ];then
|
||||
while [ "$(ifconfig | grep zt | awk '{print $1}')" = "" ]
|
||||
do
|
||||
sleep 1
|
||||
[ -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"
|
||||
|
||||
for i in ${zt0}
|
||||
do
|
||||
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
|
||||
done
|
||||
fi
|
||||
|
||||
nat_enable=$(uci get zerotier.sample_config.nat)
|
||||
zt0=$(ifconfig | grep zt | awk '{print $1}')
|
||||
|
||||
echo $zt0 > /tmp/zt.nif
|
||||
iptables -D FORWARD -i $zt0 -j ACCEPT 2>/dev/null
|
||||
iptables -D FORWARD -o $zt0 -j ACCEPT 2>/dev/null
|
||||
iptables -t nat -D POSTROUTING -o $zt0 -j MASQUERADE 2>/dev/null
|
||||
if [ $nat_enable -eq 1 ]; then
|
||||
iptables -I FORWARD -i $zt0 -j ACCEPT
|
||||
iptables -I FORWARD -o $zt0 -j ACCEPT
|
||||
iptables -t nat -I POSTROUTING -o $zt0 -j MASQUERADE
|
||||
ip_segment=$(ip route | grep "dev $zt0 proto" | awk '{print $1}')
|
||||
iptables -t nat -I POSTROUTING -s $ip_segment -j MASQUERADE
|
||||
fi
|
||||
|
||||
fi
|
||||
[ "${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" | awk '{print $1}')"
|
||||
iptables -t nat -I POSTROUTING -s "${ip_segment}" -j MASQUERADE
|
||||
done
|
||||
}
|
||||
|
@ -1,12 +1,15 @@
|
||||
#!/bin/sh
|
||||
|
||||
zt0=$(ifconfig | grep zt | awk '{print $1}')
|
||||
if [ "$zt0" = "" ]; then
|
||||
zt0=$(cat /tmp/cat /tmp/zt.nif)
|
||||
fi
|
||||
echo "zt interface $zt0 is stopped!"
|
||||
iptables -D FORWARD -i $zt0 -j ACCEPT 2>/dev/null
|
||||
iptables -D FORWARD -o $zt0 -j ACCEPT 2>/dev/null
|
||||
iptables -t nat -D POSTROUTING -o $zt0 -j MASQUERADE 2>/dev/null
|
||||
ip_segment=$(ip route | grep "dev $zt0 proto" | awk '{print $1}')
|
||||
iptables -t nat -D POSTROUTING -s $ip_segment -j MASQUERADE 2>/dev/null
|
||||
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…
x
Reference in New Issue
Block a user