2121
2222netflix () {
2323 local port=" $1 "
24- if [ " $run_mode " = " gfw " ] && [ -f " $TMP_DNSMASQ_PATH /gfw_list.conf" ] && [ -s /etc/ssrplus/netflix.list ]; then
24+ if [ -f " $TMP_DNSMASQ_PATH /gfw_list.conf" ] && [ -s /etc/ssrplus/netflix.list ]; then
2525 grep -vE ' ^\s*#|^\s*$' /etc/ssrplus/netflix.list > /tmp/ssrplus_netflix.list.clean
2626 if [ -s /tmp/ssrplus_netflix.list.clean ]; then
2727 grep -v -F -f /tmp/ssrplus_netflix.list.clean " $TMP_DNSMASQ_PATH /gfw_list.conf" > " $TMP_DNSMASQ_PATH /gfw_list.conf.tmp"
@@ -46,34 +46,16 @@ run_mode=$(uci_get_by_type global run_mode router)
4646
4747if [ " $run_mode " = " oversea" ]; then
4848 cp -rf /etc/ssrplus/oversea_list.conf $TMP_DNSMASQ_PATH /
49- elif [ " $run_mode " = " gfw " ] ; then
49+ else
5050 cp -rf /etc/ssrplus/gfw_list.conf $TMP_DNSMASQ_PATH /
5151 cp -rf /etc/ssrplus/gfw_base.conf $TMP_DNSMASQ_PATH /
52+ fi
5253
53- if [ " $nft_support " = " 1" ]; then
54- # 移除 ipset
55- for conf_file in gfw_base.conf gfw_list.conf; do
56- if [ -f " $TMP_DNSMASQ_PATH /$conf_file " ]; then
57- sed -i ' s|ipset=/\([^/]*\)/\([^[:space:]]*\)|nftset=/\1/inet#ss_spec#\2|g' " $TMP_DNSMASQ_PATH /$conf_file "
58- fi
59- done
60- fi
61-
62- # 仅在 gfw 模式下才需要从 gfw 列表中移除黑名单/白名单/拒绝列表的域名
63- # 此处使用 for 方式读取 防止 /etc/ssrplus/ 目录下的 black.list white.list deny.list 等2个或多个文件一行中存在空格 比如:# abc.com 而丢失:server
64- # Optimize: Batch filter using grep
65- for list_file in /etc/ssrplus/black.list /etc/ssrplus/white.list /etc/ssrplus/deny.list; do
66- if [ -s " $list_file " ]; then
67- grep -vE ' ^\s*#|^\s*$' " $list_file " > " ${list_file} .clean"
68- if [ -s " ${list_file} .clean" ]; then
69- for target_file in " $TMP_DNSMASQ_PATH /gfw_list.conf" " $TMP_DNSMASQ_PATH /gfw_base.conf" ; do
70- if [ -f " $target_file " ]; then
71- grep -v -F -f " ${list_file} .clean" " $target_file " > " ${target_file} .tmp"
72- mv " ${target_file} .tmp" " $target_file "
73- fi
74- done
75- fi
76- rm -f " ${list_file} .clean"
54+ if [ " $nft_support " = " 1" ]; then
55+ # 移除 ipset
56+ for conf_file in gfw_base.conf gfw_list.conf; do
57+ if [ -f " $TMP_DNSMASQ_PATH /$conf_file " ]; then
58+ sed -i ' s|ipset=/\([^/]*\)/\([^[:space:]]*\)|nftset=/\1/inet#ss_spec#\2|g' " $TMP_DNSMASQ_PATH /$conf_file "
7759 fi
7860 done
7961fi
@@ -97,6 +79,23 @@ $(uci_get_by_type global global_server nil) | $switch_server | same)
9779 ;;
9880esac
9981
82+ # 此处使用 for 方式读取 防止 /etc/ssrplus/ 目录下的 black.list white.list deny.list 等2个或多个文件一行中存在空格 比如:# abc.com 而丢失:server
83+ # Optimize: Batch filter using grep
84+ for list_file in /etc/ssrplus/black.list /etc/ssrplus/white.list /etc/ssrplus/deny.list; do
85+ if [ -s " $list_file " ]; then
86+ grep -vE ' ^\s*#|^\s*$' " $list_file " > " ${list_file} .clean"
87+ if [ -s " ${list_file} .clean" ]; then
88+ for target_file in " $TMP_DNSMASQ_PATH /gfw_list.conf" " $TMP_DNSMASQ_PATH /gfw_base.conf" ; do
89+ if [ -f " $target_file " ]; then
90+ grep -v -F -f " ${list_file} .clean" " $target_file " > " ${target_file} .tmp"
91+ mv " ${target_file} .tmp" " $target_file "
92+ fi
93+ done
94+ fi
95+ rm -f " ${list_file} .clean"
96+ fi
97+ done
98+
10099# 此处直接使用 cat 因为有 sed '/#/d' 删除了 数据
101100if [ " $nft_support " = " 1" ]; then
102101 cat /etc/ssrplus/black.list | sed ' /^$/d' | sed ' /#/d' | sed " /.*/s/.*/server=\/&\/127.0.0.1#$dns_port \nnftset=\/&\/inet#ss_spec#blacklist/" > $TMP_DNSMASQ_PATH /blacklist_forward.conf
0 commit comments