mirror of
https://github.com/fw876/helloworld.git
synced 2026-12-05 08:01:07 +00:00
Merge pull request #1838 from zxlhhyccc/tuic
luci-app-ssr-plus: optimize nftables fw4 rules and Add nftables rule persistence.
This commit is contained in:
4 files changed
+901
-184
No files matched your search
@@ -73,6 +73,10 @@ if Process_list:find("tcp.udp.ssr.retcp") then
|
||||
reudp_run = 1
|
||||
end
|
||||
|
||||
if Process_list:find("nft.ssr.retcp") then
|
||||
redir_run = 1
|
||||
end
|
||||
|
||||
if Process_list:find("local.ssr.retcp") then
|
||||
redir_run = 1
|
||||
sock5_run = 1
|
||||
|
||||
@@ -211,8 +211,10 @@ start_dns() {
|
||||
local run_mode="$(uci_get_by_type global run_mode)"
|
||||
|
||||
if [ "$ssrplus_dns" != "0" ]; then
|
||||
if [ -n "$dnsserver" ]; then
|
||||
add_dns_into_ipset $run_mode $dnsserver
|
||||
if command -v iptables-legacy >/dev/null 2>&1; then
|
||||
if [ -n "$dnsserver" ]; then
|
||||
add_dns_into_ipset $run_mode $dnsserver
|
||||
fi
|
||||
fi
|
||||
case "$ssrplus_dns" in
|
||||
1)
|
||||
@@ -236,7 +238,9 @@ start_dns() {
|
||||
output=$(for i in $(echo $mosdns_dnsserver | sed "s/,/ /g"); do
|
||||
dnsserver=${i%:*}
|
||||
dnsserver=${i##*/}
|
||||
add_dns_into_ipset $run_mode $dnsserver
|
||||
if command -v iptables-legacy >/dev/null 2>&1; then
|
||||
add_dns_into_ipset $run_mode $dnsserver
|
||||
fi
|
||||
echo " - addr: $i"
|
||||
echo " enable_pipeline: true"
|
||||
done)
|
||||
@@ -1172,7 +1176,17 @@ load_config() {
|
||||
tcp_config_file=$TMP_PATH/tcp-only-ssr-retcp.json
|
||||
case "$UDP_RELAY_SERVER" in
|
||||
nil)
|
||||
mode="tcp"
|
||||
if command -v nft >/dev/null 2>&1; then
|
||||
# nftables / fw4
|
||||
mode="tcp,udp"
|
||||
ARG_UDP=""
|
||||
udp_config_file=""
|
||||
UDP_RELAY_SERVER="nil"
|
||||
tcp_config_file=$TMP_PATH/nft-ssr-retcp.json
|
||||
else
|
||||
# iptables / fw3
|
||||
mode="tcp"
|
||||
fi
|
||||
;;
|
||||
$GLOBAL_SERVER | same)
|
||||
mode="tcp,udp"
|
||||
@@ -1185,7 +1199,13 @@ load_config() {
|
||||
udp_config_file=$TMP_PATH/udp-only-ssr-reudp.json
|
||||
ARG_UDP="-U"
|
||||
start_udp
|
||||
mode="tcp"
|
||||
if command -v nft >/dev/null 2>&1; then
|
||||
# nftables / fw4
|
||||
mode="tcp,udp"
|
||||
else
|
||||
# iptables / fw3
|
||||
mode="tcp"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
case "$LOCAL_SERVER" in
|
||||
@@ -1419,6 +1439,11 @@ start_rules() {
|
||||
2) echo "-O" ;;
|
||||
esac
|
||||
}
|
||||
if command -v nft >/dev/null 2>&1; then
|
||||
ARG_A="-A"
|
||||
else
|
||||
ARG_A=""
|
||||
fi
|
||||
/usr/share/shadowsocksr/gfw2ipset.sh
|
||||
/usr/bin/ssr-rules \
|
||||
-s "$server" \
|
||||
@@ -1438,7 +1463,8 @@ start_rules() {
|
||||
-N "$shunt_ip" \
|
||||
-M "$(uci_get_by_type global netflix_proxy 0)" \
|
||||
-I "/etc/ssrplus/netflixip.list" \
|
||||
$(get_arg_out) $(gfwmode) $ARG_UDP
|
||||
$(get_arg_out) $(gfwmode) $ARG_UDP $ARG_A
|
||||
|
||||
return $?
|
||||
}
|
||||
|
||||
@@ -1486,6 +1512,13 @@ boot() {
|
||||
stop() {
|
||||
unlock
|
||||
set_lock
|
||||
if command -v nft >/dev/null 2>&1; then
|
||||
/usr/bin/ssr-rules -K
|
||||
local CLEANUP_PERSISTENCE="$(uci_get_by_type global global_server nil)"
|
||||
if [ "$CLEANUP_PERSISTENCE" == "nil" ]; then
|
||||
/usr/bin/ssr-rules -X
|
||||
fi
|
||||
fi
|
||||
/usr/bin/ssr-rules -f
|
||||
local srulecount=0
|
||||
if command -v nft >/dev/null 2>&1; then
|
||||
@@ -1527,6 +1560,7 @@ stop() {
|
||||
killall -q -9 kcptun-client
|
||||
fi
|
||||
$PS -w | grep -v "grep" | grep ssr-monitor | awk '{print $1}' | xargs kill -9 >/dev/null 2>&1 &
|
||||
$PS -w | grep -v "grep" | grep ssr-rules | awk '{print $1}' | xargs kill -9 >/dev/null 2>&1 &
|
||||
$PS -w | grep -v "grep" | grep "sleep 0000" | awk '{print $1}' | xargs kill -9 >/dev/null 2>&1 &
|
||||
( \
|
||||
# Graceful kill first, so programs have the chance to stop its subprocesses
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -213,7 +213,9 @@ local function update(url, file, type, file2)
|
||||
if type == "gfw_data" or type == "ad_data" then
|
||||
luci.sys.call("/usr/share/shadowsocksr/gfw2ipset.sh")
|
||||
else
|
||||
luci.sys.call("/usr/share/shadowsocksr/chinaipset.sh " .. TMP_PATH .. "/china_ssr.txt")
|
||||
if luci.sys.call("command -v ipset >/dev/null 2>&1") == 0 then
|
||||
luci.sys.call("/usr/share/shadowsocksr/chinaipset.sh " .. TMP_PATH .. "/china_ssr.txt")
|
||||
end
|
||||
end
|
||||
if args then
|
||||
log(0, tonumber(icount) / Num)
|
||||
|
||||
Reference in new issue
Block a user