Skip to content

Commit d0bc752

Browse files
committed
passwall : optimize
1 parent c1cb684 commit d0bc752

File tree

10 files changed

+67
-77
lines changed

10 files changed

+67
-77
lines changed

lienol/luci-app-passwall/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk
77

88
PKG_NAME:=luci-app-passwall
99
PKG_VERSION:=3.3
10-
PKG_RELEASE:=35-20200123
10+
PKG_RELEASE:=36-20200124
1111

1212
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
1313

lienol/luci-app-passwall/root/etc/config/passwall

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ config global_delay
2222

2323
config global_forwarding
2424
option udp_redir_ports '1:65535'
25-
option tcp_redir_ports '80,443'
25+
option tcp_redir_ports '1:65535'
2626
option process '1'
2727

2828
config global_proxy
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
formyip.com
2-
myepisodecalendar.com
3-
subhd.com
4-
msi.com
2+
msi.com
3+
github.com
4+
github.io
5+
githubusercontent.com

lienol/luci-app-passwall/root/etc/config/passwall_rule/router

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
google.com
22
youtube.com
33
github.com
4-
raw.githubusercontent.com
4+
github.io
5+
githubusercontent.com
56
github-production-release-asset-2e65be.s3.amazonaws.com
67
openwrt.proxy.ustclug.org
78
easylist-downloads.adblockplus.org

lienol/luci-app-passwall/root/usr/share/passwall/app.sh

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ APP_PATH=/usr/share/$CONFIG
2323
TMP_DNSMASQ_PATH=/var/etc/dnsmasq-passwall.d
2424
DNSMASQ_PATH=/etc/dnsmasq.d
2525
RESOLVFILE=/tmp/resolv.conf.d/resolv.conf.auto
26-
lanip=$(uci get network.lan.ipaddr)
26+
lanip=$(uci -q get network.lan.ipaddr)
2727
DNS_PORT=7913
2828
API_GEN_V2RAY=/usr/lib/lua/luci/model/cbi/passwall/api/gen_v2ray_client_config_file.lua
2929
API_GEN_TROJAN=/usr/lib/lua/luci/model/cbi/passwall/api/gen_trojan_client_config_file.lua
@@ -48,14 +48,14 @@ find_bin() {
4848
}
4949

5050
config_n_get() {
51-
local ret=$(uci get $CONFIG.$1.$2 2>/dev/null)
51+
local ret=$(uci -q get $CONFIG.$1.$2 2>/dev/null)
5252
echo ${ret:=$3}
5353
}
5454

5555
config_t_get() {
5656
local index=0
5757
[ -n "$4" ] && index=$4
58-
local ret=$(uci get $CONFIG.@$1[$index].$2 2>/dev/null)
58+
local ret=$(uci -q get $CONFIG.@$1[$index].$2 2>/dev/null)
5959
echo ${ret:=$3}
6060
}
6161

@@ -78,10 +78,10 @@ get_host_ip() {
7878
if [ -z "$isip" ]; then
7979
vpsrip=""
8080
if [ "$use_ipv6" == "1" ]; then
81-
vpsrip=$(resolveip -6 -t 2 $host | awk 'NR==1{print}')
81+
vpsrip=$(resolveip -6 -t 3 $host | awk 'NR==1{print}')
8282
[ -z "$vpsrip" ] && vpsrip=$(dig @208.67.222.222 $host AAAA 2>/dev/null | grep 'IN' | awk -F ' ' '{print $5}' | grep -E "([a-f0-9]{1,4}(:[a-f0-9]{1,4}){7}|[a-f0-9]{1,4}(:[a-f0-9]{1,4}){0,7}::[a-f0-9]{0,4}(:[a-f0-9]{1,4}){0,7})" | head -n1)
8383
else
84-
vpsrip=$(resolveip -4 -t 2 $host | awk 'NR==1{print}')
84+
vpsrip=$(resolveip -4 -t 3 $host | awk 'NR==1{print}')
8585
[ -z "$vpsrip" ] && vpsrip=$(dig @208.67.222.222 $host 2>/dev/null | grep 'IN' | awk -F ' ' '{print $5}' | grep -E "([0-9]{1,3}[\.]){3}[0-9]{1,3}" | head -n1)
8686
fi
8787
ip=$vpsrip
@@ -94,11 +94,11 @@ check_port_exists() {
9494
protocol=$2
9595
result=
9696
if [ "$protocol" = "tcp" ]; then
97-
result=$(netstat -tlpn | grep "\<$port\>")
97+
result=$(netstat -tln | grep -c ":$port")
9898
elif [ "$protocol" = "udp" ]; then
99-
result=$(netstat -ulpn | grep "\<$port\>")
99+
result=$(netstat -uln | grep -c ":$port")
100100
fi
101-
if [ -n "$result" ]; then
101+
if [ "$result" = 1 ]; then
102102
echo 1
103103
else
104104
echo 0
@@ -805,7 +805,7 @@ add_dnsmasq() {
805805
# sed -i '/except-interface/d' /etc/dnsmasq.conf >/dev/null 2>&1 &
806806
# for wanname in $(cat /var/state/network |grep pppoe|awk -F '.' '{print $2}')
807807
# do
808-
# echo "except-interface=$(uci get network.$wanname.ifname)" >>/etc/dnsmasq.conf
808+
# echo "except-interface=$(uci -q get network.$wanname.ifname)" >>/etc/dnsmasq.conf
809809
# done
810810
# fi
811811

lienol/luci-app-passwall/root/usr/share/passwall/iptables.sh

Lines changed: 35 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -244,12 +244,14 @@ add_firewall_rule() {
244244
$iptables_nat -A PSW $(dst $IPSET_VPSIPLIST) -j RETURN
245245
$iptables_nat -A PSW $(dst $IPSET_WHITELIST) -j RETURN
246246
$iptables_nat -N PSW_ACL
247+
$iptables_nat -N PSW_OUTPUT
247248

248249
$iptables_mangle -N PSW
249250
$iptables_mangle -A PSW $(dst $IPSET_LANIPLIST) -j RETURN
250251
$iptables_mangle -A PSW $(dst $IPSET_VPSIPLIST) -j RETURN
251252
$iptables_mangle -A PSW $(dst $IPSET_WHITELIST) -j RETURN
252253
$iptables_mangle -N PSW_ACL
254+
$iptables_mangle -N PSW_OUTPUT
253255

254256
if [[ "$TCP_NODE_NUM" -ge 1 ]] || [[ "$UDP_NODE_NUM" -ge 1 ]]; then
255257
local max_num=1
@@ -322,7 +324,7 @@ add_firewall_rule() {
322324

323325
# 用于本机流量转发,默认只走router
324326
$iptables_mangle -A PSW -s $lan_ip -p tcp $(dst $IPSET_ROUTER) -j TPROXY --tproxy-mark 0x1/0x1 --on-port $local_port
325-
$iptables_mangle -A OUTPUT -p tcp -m multiport --dport $TCP_REDIR_PORTS $(dst $IPSET_ROUTER) $iptables_comment -j MARK --set-mark 1
327+
$iptables_mangle -A PSW_OUTPUT -p tcp -m multiport --dport $TCP_REDIR_PORTS $(dst $IPSET_ROUTER) -j MARK --set-mark 1
326328
else
327329
# 全局模式
328330
$iptables_nat -A PSW_GLO$k -p tcp -j REDIRECT --to-ports $local_port
@@ -382,27 +384,27 @@ add_firewall_rule() {
382384
fi
383385
$iptables_nat -I PREROUTING $PR_INDEX -j PSW
384386
fi
385-
# 用于本机流量转发,默认只走router
386-
#$iptables_nat -I OUTPUT -j PSW
387-
$iptables_nat -A OUTPUT $(dst $IPSET_LANIPLIST) $iptables_comment -j RETURN
387+
# 用于本机流量转发
388+
$iptables_nat -A OUTPUT -j PSW_OUTPUT
389+
$iptables_nat -A PSW_OUTPUT $(dst $IPSET_LANIPLIST) -j RETURN
388390
[ "$use_tcp_node_resolve_dns" == 1 -a -n "$DNS_FORWARD" ] && {
389391
for dns in $DNS_FORWARD
390392
do
391393
local dns_ip=$(echo $dns | awk -F "#" '{print $1}')
392394
local dns_port=$(echo $dns | awk -F "#" '{print $2}')
393395
[ -z "$dns_port" ] && dns_port=53
394-
$iptables_nat -A OUTPUT -p tcp -d $dns_ip --dport $dns_port $iptables_comment -j REDIRECT --to-ports $TCP_REDIR_PORT1
396+
$iptables_nat -A PSW_OUTPUT -p tcp -d $dns_ip --dport $dns_port -j REDIRECT --to-ports $TCP_REDIR_PORT1
395397
done
396398
}
397-
$iptables_nat -A OUTPUT $(dst $IPSET_VPSIPLIST) $iptables_comment -j RETURN
398-
$iptables_nat -A OUTPUT $(dst $IPSET_WHITELIST) $iptables_comment -j RETURN
399-
$iptables_nat -A OUTPUT -p tcp -m multiport --dport $TCP_REDIR_PORTS $(dst $IPSET_ROUTER) $iptables_comment -j REDIRECT --to-ports $TCP_REDIR_PORT1
400-
$iptables_nat -A OUTPUT -p tcp -m multiport --dport $TCP_REDIR_PORTS $(dst $IPSET_BLACKLIST) $iptables_comment -j REDIRECT --to-ports $TCP_REDIR_PORT1
399+
$iptables_nat -A PSW_OUTPUT $(dst $IPSET_VPSIPLIST) -j RETURN
400+
$iptables_nat -A PSW_OUTPUT $(dst $IPSET_WHITELIST) -j RETURN
401+
$iptables_nat -A PSW_OUTPUT -p tcp -m multiport --dport $TCP_REDIR_PORTS $(dst $IPSET_ROUTER) -j REDIRECT --to-ports $TCP_REDIR_PORT1
402+
$iptables_nat -A PSW_OUTPUT -p tcp -m multiport --dport $TCP_REDIR_PORTS $(dst $IPSET_BLACKLIST) -j REDIRECT --to-ports $TCP_REDIR_PORT1
401403

402-
[ "$LOCALHOST_PROXY_MODE" == "global" ] && $iptables_nat -A OUTPUT -p tcp -m multiport --dport $TCP_REDIR_PORTS $iptables_comment -j REDIRECT --to-ports $TCP_REDIR_PORT1
403-
[ "$LOCALHOST_PROXY_MODE" == "gfwlist" ] && $iptables_nat -A OUTPUT -p tcp -m multiport --dport $TCP_REDIR_PORTS $(dst $IPSET_GFW) $iptables_comment -j REDIRECT --to-ports $TCP_REDIR_PORT1
404+
[ "$LOCALHOST_PROXY_MODE" == "global" ] && $iptables_nat -A PSW_OUTPUT -p tcp -m multiport --dport $TCP_REDIR_PORTS -j REDIRECT --to-ports $TCP_REDIR_PORT1
405+
[ "$LOCALHOST_PROXY_MODE" == "gfwlist" ] && $iptables_nat -A PSW_OUTPUT -p tcp -m multiport --dport $TCP_REDIR_PORTS $(dst $IPSET_GFW) -j REDIRECT --to-ports $TCP_REDIR_PORT1
404406
[ "$LOCALHOST_PROXY_MODE" == "chnroute" ] && {
405-
$iptables_nat -A OUTPUT -p tcp -m multiport --dport $TCP_REDIR_PORTS -m set ! --match-set $IPSET_CHN dst $iptables_comment -j REDIRECT --to-ports $TCP_REDIR_PORT1
407+
$iptables_nat -A PSW_OUTPUT -p tcp -m multiport --dport $TCP_REDIR_PORTS -m set ! --match-set $IPSET_CHN dst -j REDIRECT --to-ports $TCP_REDIR_PORT1
406408
}
407409
}
408410
# 重定所有流量到透明代理端口
@@ -467,27 +469,28 @@ add_firewall_rule() {
467469
$iptables_mangle -A PSW_GAME$k -p udp $(dst $IPSET_CHN) -j RETURN
468470
$iptables_mangle -A PSW_GAME$k -p udp -j TPROXY --tproxy-mark 0x1/0x1 --on-port $local_port
469471

470-
# 用于本机流量转发,默认只走router
471-
$iptables_mangle -A OUTPUT -p udp $(dst $IPSET_LANIPLIST) $iptables_comment -j RETURN
472+
# 用于本机流量转发
473+
$iptables_mangle -A OUTPUT -j PSW_OUTPUT
474+
$iptables_mangle -A PSW_OUTPUT -p udp $(dst $IPSET_LANIPLIST) -j RETURN
472475
[ "$use_udp_node_resolve_dns" == 1 -a -n "$DNS_FORWARD" ] && {
473476
for dns in $DNS_FORWARD
474477
do
475478
local dns_ip=$(echo $dns | awk -F "#" '{print $1}')
476479
local dns_port=$(echo $dns | awk -F "#" '{print $2}')
477480
[ -z "$dns_port" ] && dns_port=53
478-
$iptables_mangle -A OUTPUT -p udp -d $dns_ip --dport $dns_port $iptables_comment -j MARK --set-mark 1
479-
$iptables_mangle -I PSW 2 -p udp -d $dns_ip --dport $dns_port $iptables_comment -j TPROXY --tproxy-mark 0x1/0x1 --on-port $local_port
481+
$iptables_mangle -A PSW_OUTPUT -p udp -d $dns_ip --dport $dns_port -j MARK --set-mark 1
482+
$iptables_mangle -I PSW 2 -p udp -d $dns_ip --dport $dns_port -j TPROXY --tproxy-mark 0x1/0x1 --on-port $local_port
480483
done
481484
}
482-
$iptables_mangle -A OUTPUT -p udp $(dst $IPSET_VPSIPLIST) $iptables_comment -j RETURN
483-
$iptables_mangle -A OUTPUT -p udp $(dst $IPSET_WHITELIST) $iptables_comment -j RETURN
484-
$iptables_mangle -A OUTPUT -p udp -m multiport --dport $UDP_REDIR_PORTS $(dst $IPSET_ROUTER) $iptables_comment -j MARK --set-mark 1
485-
$iptables_mangle -A OUTPUT -p udp -m multiport --dport $UDP_REDIR_PORTS $(dst $IPSET_BLACKLIST) $iptables_comment -j MARK --set-mark 1
485+
$iptables_mangle -A PSW_OUTPUT -p udp $(dst $IPSET_VPSIPLIST) -j RETURN
486+
$iptables_mangle -A PSW_OUTPUT -p udp $(dst $IPSET_WHITELIST) -j RETURN
487+
$iptables_mangle -A PSW_OUTPUT -p udp -m multiport --dport $UDP_REDIR_PORTS $(dst $IPSET_ROUTER) -j MARK --set-mark 1
488+
$iptables_mangle -A PSW_OUTPUT -p udp -m multiport --dport $UDP_REDIR_PORTS $(dst $IPSET_BLACKLIST) -j MARK --set-mark 1
486489

487-
[ "$LOCALHOST_PROXY_MODE" == "global" ] && $iptables_mangle -A OUTPUT -p udp -m multiport --dport $UDP_REDIR_PORTS $iptables_comment -j MARK --set-mark 1
488-
[ "$LOCALHOST_PROXY_MODE" == "gfwlist" ] && $iptables_mangle -A OUTPUT -p udp -m multiport --dport $UDP_REDIR_PORTS $(dst $IPSET_GFW) $iptables_comment -j MARK --set-mark 1
490+
[ "$LOCALHOST_PROXY_MODE" == "global" ] && $iptables_mangle -A PSW_OUTPUT -p udp -m multiport --dport $UDP_REDIR_PORTS -j MARK --set-mark 1
491+
[ "$LOCALHOST_PROXY_MODE" == "gfwlist" ] && $iptables_mangle -A PSW_OUTPUT -p udp -m multiport --dport $UDP_REDIR_PORTS $(dst $IPSET_GFW) -j MARK --set-mark 1
489492
[ "$LOCALHOST_PROXY_MODE" == "chnroute" ] && {
490-
$iptables_mangle -A OUTPUT -p udp -m multiport --dport $UDP_REDIR_PORTS -m set ! --match-set $IPSET_CHN dst $iptables_comment -j MARK --set-mark 1
493+
$iptables_mangle -A PSW_OUTPUT -p udp -m multiport --dport $UDP_REDIR_PORTS -m set ! --match-set $IPSET_CHN dst -j MARK --set-mark 1
491494
}
492495

493496
echolog "IPv4 防火墙UDP转发规则加载完成!"
@@ -505,9 +508,9 @@ add_firewall_rule() {
505508
local ip=$(echo $balancing_node | awk -F ":" '{print $1}')
506509
local port=$(echo $balancing_node | awk -F ":" '{print $2}')
507510
$iptables_nat -I PSW 2 -p tcp -d $ip --dport $port -j RETURN
508-
$iptables_nat -I OUTPUT 2 -p tcp -d $ip --dport $port $iptables_comment -j RETURN
511+
$iptables_nat -I PSW_OUTPUT 2 -p tcp -d $ip --dport $port -j RETURN
509512
$iptables_mangle -I PSW 2 -p udp -d $ip --dport $port -j RETURN
510-
$iptables_mangle -I OUTPUT 2 -p udp -d $ip --dport $port $iptables_comment -j RETURN
513+
$iptables_mangle -I PSW_OUTPUT 2 -p udp -d $ip --dport $port -j RETURN
511514
done
512515
fi
513516

@@ -534,30 +537,6 @@ add_firewall_rule() {
534537

535538
del_firewall_rule() {
536539
echolog "删除所有防火墙规则..."
537-
ipv4_output_exist=$($iptables_nat -L OUTPUT 2>/dev/null | grep -c -E "PassWall")
538-
[ -n "$ipv4_output_exist" ] && {
539-
until [ "$ipv4_output_exist" = 0 ]; do
540-
rules=$($iptables_nat -L OUTPUT --line-numbers | grep -E "PassWall" | awk '{print $1}')
541-
for rule in $rules; do
542-
$iptables_nat -D OUTPUT $rule 2>/dev/null
543-
break
544-
done
545-
ipv4_output_exist=$(expr $ipv4_output_exist - 1)
546-
done
547-
}
548-
549-
ipv4_output_exist=$($iptables_mangle -L OUTPUT 2>/dev/null | grep -c -E "PassWall")
550-
[ -n "$ipv4_output_exist" ] && {
551-
until [ "$ipv4_output_exist" = 0 ]; do
552-
rules=$($iptables_mangle -L OUTPUT --line-numbers | grep -E "PassWall" | awk '{print $1}')
553-
for rule in $rules; do
554-
$iptables_mangle -D OUTPUT $rule 2>/dev/null
555-
break
556-
done
557-
ipv4_output_exist=$(expr $ipv4_output_exist - 1)
558-
done
559-
}
560-
561540
ipv6_output_ss_exist=$($ip6tables_nat -L OUTPUT 2>/dev/null | grep -c "PSW")
562541
[ -n "$ipv6_output_ss_exist" ] && {
563542
until [ "$ipv6_output_ss_exist" = 0 ]; do
@@ -571,16 +550,22 @@ del_firewall_rule() {
571550
}
572551

573552
$iptables_nat -D PREROUTING -j PSW 2>/dev/null
553+
$iptables_nat -D OUTPUT -j PSW_OUTPUT 2>/dev/null
574554
$iptables_nat -F PSW 2>/dev/null && $iptables_nat -X PSW 2>/dev/null
575555
$iptables_nat -F PSW_ACL 2>/dev/null && $iptables_nat -X PSW_ACL 2>/dev/null
556+
$iptables_nat -F PSW_OUTPUT 2>/dev/null && $iptables_nat -X PSW_OUTPUT 2>/dev/null
576557

577-
$iptables_mangle -D PREROUTING -j PSW$k 2>/dev/null
558+
$iptables_mangle -D PREROUTING -j PSW 2>/dev/null
559+
$iptables_mangle -D OUTPUT -j PSW_OUTPUT 2>/dev/null
578560
$iptables_mangle -F PSW 2>/dev/null && $iptables_mangle -X PSW 2>/dev/null
579561
$iptables_mangle -F PSW_ACL 2>/dev/null && $iptables_mangle -X PSW_ACL 2>/dev/null
562+
$iptables_mangle -F PSW_OUTPUT 2>/dev/null && $iptables_mangle -X PSW_OUTPUT 2>/dev/null
580563

581564
$ip6tables_nat -D PREROUTING -j PSW 2>/dev/null
565+
$ip6tables_nat -D OUTPUT -j PSW_OUTPUT 2>/dev/null
582566
$ip6tables_nat -F PSW 2>/dev/null && $ip6tables_nat -X PSW 2>/dev/null
583567
$ip6tables_nat -F PSW_ACL 2>/dev/null && $ip6tables_nat -X PSW_ACL 2>/dev/null
568+
$ip6tables_nat -F PSW_OUTPUT 2>/dev/null && $ip6tables_nat -X PSW_OUTPUT 2>/dev/null
584569

585570
local max_num=5
586571
if [ "$max_num" -ge 1 ]; then

lienol/luci-app-passwall/root/usr/share/passwall/monitor.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ CONFIG=passwall
44
CONFIG_PATH=/var/etc/$CONFIG
55

66
config_n_get() {
7-
local ret=$(uci get $CONFIG.$1.$2 2>/dev/null)
7+
local ret=$(uci -q get $CONFIG.$1.$2 2>/dev/null)
88
echo ${ret:=$3}
99
}
1010

1111
config_t_get() {
1212
local index=0
1313
[ -n "$4" ] && index=$4
14-
local ret=$(uci get $CONFIG.@$1[$index].$2 2>/dev/null)
14+
local ret=$(uci -q get $CONFIG.@$1[$index].$2 2>/dev/null)
1515
echo ${ret:=$3}
1616
}
1717

lienol/luci-app-passwall/root/usr/share/passwall/rule_update.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ if [ -n "$update" ]; then
1515
[ -n "$(echo $update | grep "chnroute_update")" ] && chnroute_update=1
1616
[ -n "$(echo $update | grep "chnlist_update")" ] && chnlist_update=1
1717
else
18-
gfwlist_update=$(uci get $CONFIG.@global_rules[0].gfwlist_update)
19-
chnroute_update=$(uci get $CONFIG.@global_rules[0].chnroute_update)
20-
chnlist_update=$(uci get $CONFIG.@global_rules[0].chnlist_update)
18+
gfwlist_update=$(uci -q get $CONFIG.@global_rules[0].gfwlist_update)
19+
chnroute_update=$(uci -q get $CONFIG.@global_rules[0].chnroute_update)
20+
chnlist_update=$(uci -q get $CONFIG.@global_rules[0].chnlist_update)
2121
fi
2222

2323
if [ "$gfwlist_update" == 0 -a "$chnroute_update" == 0 -a "$chnlist_update" == 0 ]; then
@@ -29,7 +29,7 @@ uci_get_by_type() {
2929
if [ -n $4 ]; then
3030
index=$4
3131
fi
32-
local ret=$(uci get $CONFIG.@$1[$index].$2 2>/dev/null)
32+
local ret=$(uci -q get $CONFIG.@$1[$index].$2 2>/dev/null)
3333
echo ${ret:=$3}
3434
}
3535

lienol/luci-app-passwall/root/usr/share/passwall/subscription.sh

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ LOG_FILE=/var/log/$CONFIG.log
1111
config_t_get() {
1212
local index=0
1313
[ -n "$3" ] && index=$3
14-
local ret=$(uci get $CONFIG.@$1[$index].$2 2>/dev/null)
14+
local ret=$(uci -q get $CONFIG.@$1[$index].$2 2>/dev/null)
1515
#echo ${ret:=$3}
1616
echo $ret
1717
}
@@ -413,7 +413,7 @@ del_config(){
413413
[ "`cat /usr/share/${CONFIG}/sub/all_onlinenodes |grep -c "$localaddress"`" -eq 0 ] && {
414414
for localindex in $(uci show $CONFIG | grep -w "$localaddress" | grep -w "address=" |cut -d '[' -f2|cut -d ']' -f1)
415415
do
416-
del_type=$(uci get $CONFIG.@nodes[$localindex].type)
416+
del_type=$(uci -q get $CONFIG.@nodes[$localindex].type)
417417
uci delete $CONFIG.@nodes[$localindex]
418418
uci commit $CONFIG
419419
if [ "$del_type" == "SS" ]; then
@@ -434,17 +434,20 @@ del_config(){
434434
del_all_config(){
435435
get_node_index
436436
[ "`uci show $CONFIG | grep -c 'is_sub'`" -eq 0 ] && exit 0
437-
TCP_NODE_NUM=$(uci get $CONFIG.@global_other[0].tcp_node_num)
437+
TCP_NODE_NUM=$(uci -q get $CONFIG.@global_other[0].tcp_node_num)
438+
[ -z "$TCP_NODE_NUM" ] && TCP_NODE_NUM=1
438439
for i in $(seq 1 $TCP_NODE_NUM); do
439440
eval TCP_NODE$i=$(config_t_get global tcp_node$i)
440441
done
441442

442-
UDP_NODE_NUM=$(uci get $CONFIG.@global_other[0].udp_node_num)
443+
UDP_NODE_NUM=$(uci -q get $CONFIG.@global_other[0].udp_node_num)
444+
[ -z "$UDP_NODE_NUM" ] && UDP_NODE_NUM=1
443445
for i in $(seq 1 $UDP_NODE_NUM); do
444446
eval UDP_NODE$i=$(config_t_get global udp_node$i)
445447
done
446448

447-
SOCKS5_NODE_NUM=$(uci get $CONFIG.@global_other[0].socks5_node_num)
449+
SOCKS5_NODE_NUM=$(uci -q get $CONFIG.@global_other[0].socks5_node_num)
450+
[ -z "$SOCKS5_NODE_NUM" ] && SOCKS5_NODE_NUM=1
448451
for i in $(seq 1 $SOCKS5_NODE_NUM); do
449452
eval SOCKS5_NODE$i=$(config_t_get global socks5_node$i)
450453
done

lienol/luci-app-passwall/root/usr/share/passwall/test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ test_auto_switch() {
5656
let "failcount++"
5757
[ "$failcount" -ge 5 ] && {
5858
echolog "自动切换检测:检测异常,切换节点"
59-
TCP_NODES=$(uci get $CONFIG.@auto_switch[0].tcp_node)
59+
TCP_NODES=$(uci -q get $CONFIG.@auto_switch[0].tcp_node)
6060
has_backup_server=$(echo $TCP_NODES | grep $TCP_NODES1)
6161
setserver=
6262
if [ -z "$has_backup_server" ]; then

0 commit comments

Comments
 (0)