update 2024-01-02 16:23:01

This commit is contained in:
github-actions[bot] 2024-01-02 16:23:01 +08:00
parent 8745615ebe
commit 64b646830e
6 changed files with 68 additions and 19 deletions

View File

@ -4,7 +4,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-natter2
PKG_VERSION:=1.0
PKG_RELEASE:=1
PKG_RELEASE:=2
LUCI_TITLE:=LuCI Support for Natter v2.0.0-rc1
LUCI_PKGARCH:=all

View File

@ -19,9 +19,12 @@ enable.default = 0
if check_file("/tmp/natter2_nat_type") then
natter_nat_type_tcp = luci.sys.exec ("grep TCP /tmp/natter2_nat_type")
natter_nat_type_udp = luci.sys.exec ("grep UDP /tmp/natter2_nat_type")
nat_check = s:option (Button, "nat_check", translate("Check NAT Status"), translate("Proxy programs may affect NAT types") .. "<br><br>" .. natter_nat_type_tcp .. "<br><br>" .. natter_nat_type_udp)
nat_check = s:option (Button, "nat_check", translate("Check NAT Status"), translate("") .. "<br><br>" .. natter_nat_type_tcp .. "<br><br>" .. natter_nat_type_udp)
else
nat_check = s:option (Button, "nat_check", translate("Check NAT Status"))
nat_check = s:option (Button, "nat_check", translate("Check NAT Status"), translate("Tips")
.. [[<br />]] .. translate("Recommended to accept high UDP ports in system firewall")
.. [[<br />]] .. translate("Turn off transparent proxies to ensure detection accuracy")
.. [[<br />]] .. translate("After clicking Exec button, please wait for the luci to refresh"))
end
nat_check.inputtitle = translate("Exec")

View File

@ -1,5 +1,5 @@
msgid "Natter v2"
msgstr "Natter v2"
msgstr "Natter v2 测试版"
msgid "Base Settings"
msgstr "基础设置"
@ -141,3 +141,15 @@ msgstr "使用自定义的 STUN 服务器"
msgid "Using customized Keepalive server"
msgstr "使用自定义的保活服务器"
msgid "Tips"
msgstr "提示"
msgid "Recommended to accept high UDP ports in system firewall"
msgstr "建议在防火墙中放行高位 UDP 端口"
msgid "Turn off transparent proxies to ensure detection accuracy"
msgstr "关闭透明代理以确保检测准确性"
msgid "After clicking Exec button, please wait for the luci to refresh"
msgstr "点击执行后,请耐心等待页面自动刷新"

View File

@ -1,5 +1,5 @@
msgid "Natter v2"
msgstr "Natter v2"
msgstr "Natter v2 测试版"
msgid "Base Settings"
msgstr "基础设置"
@ -141,3 +141,15 @@ msgstr "使用自定义的 STUN 服务器"
msgid "Using customized Keepalive server"
msgstr "使用自定义的保活服务器"
msgid "Tips"
msgstr "提示"
msgid "Recommended to accept high UDP ports in system firewall"
msgstr "建议在防火墙中放行高位 UDP 端口"
msgid "Turn off transparent proxies to ensure detection accuracy"
msgstr "关闭透明代理以确保检测准确性"
msgid "After clicking Exec button, please wait for the luci to refresh"
msgstr "点击执行后,请耐心等待页面自动刷新"

View File

@ -24,7 +24,7 @@ start_service() {
for i in $instance_list
do
local eval $i="$(uci_get_by_type instances $u $i)"
echo "$i : $(uci_get_by_type instances $u $i)"
# echo "$i : $(uci_get_by_type instances $u $i)"
done ; unset i
[ "$enable_instance" != 1 ] && continue
@ -74,8 +74,8 @@ start_service() {
cp -a /usr/share/luci-app-natter2/notify-base.sh $var_file
chmod +x $var_file
echo "log_file: $log_file"
echo "var_file: $var_file"
# echo "log_file: $log_file"
# echo "var_file: $var_file"
sleep $delay
for i in $(ps -efww | grep "$script_path" | grep -v grep | grep -v $$ | grep "$id" | awk '{print $1}')
@ -108,6 +108,7 @@ stop_service() {
uci set natter2.@instances[$u].tmp_public_port=""
uci commit natter2
done
rm -f /tmp/natter2_nat_type
}
restart() {

View File

@ -1,18 +1,39 @@
#!/bin/sh
script_file='/usr/share/natter2/natter-check/natter-check.py'
tmp_path=$(uci get natter2.@base[0].tmp_path)
[ ! "$tmp_path" ] && tmp_path="/tmp/natter2"
natter2_nat_type_file="/tmp/natter2_nat_type"
tmp_natter2_nat_type_file="/tmp/tmp_natter2_nat_type"
rm -f $natter2_nat_type_file
rm -f $tmp_natter2_nat_type_file
$(which python) $script_file | egrep 'Checking TCP|Checking UDP' > $tmp_natter2_nat_type_file
TCP=$(awk -F '[:]+' '/TCP/{print $2}' $tmp_natter2_nat_type_file | sed 's/\[//g;s/\]//g')
UDP=$(awk -F '[:]+' '/UDP/{print $2}' $tmp_natter2_nat_type_file | sed 's/\[//g;s/\]//g')
mkdir -p $tmp_path
rm -f /tmp/natter2_nat_type
rm -f $tmp_path/natter2_nat_type.tmp
python3 $script_file | egrep 'Checking TCP|Checking UDP' > $tmp_path/natter2_nat_type.tmp
TCP=$(awk -F '[:]+' '/TCP/{print $2}' $tmp_path/natter2_nat_type.tmp | sed 's/\[//g;s/\]//g')
UDP=$(awk -F '[:]+' '/UDP/{print $2}' $tmp_path/natter2_nat_type.tmp | sed 's/\[//g;s/\]//g')
rm -f $tmp_path/natter2_nat_type.tmp
[ ! "$TCP" ] && TCP="未知"
[ ! "$UDP" ] && UDP="未知"
echo "TCP: NAT $TCP" > /tmp/natter2_nat_type
echo "UDP: NAT $UDP" >> /tmp/natter2_nat_type
function NAT_Type() {
case $1 in
0)
echo "Public Network"
;;
1)
echo "Full Cone"
;;
2)
echo "Restricted Cone"
;;
3)
echo "Port Restricted Cone"
;;
4)
echo "Symmetric"
;;
esac
}
echo "TCP: NAT $TCP | $(NAT_Type $TCP)" > $natter2_nat_type_file
echo "UDP: NAT $UDP | $(NAT_Type $UDP)" >> $natter2_nat_type_file
rm -f $tmp_natter2_nat_type_file