luci-app-ssr-plus: fix ssrp alwawys start two server (#3875)

This commit is contained in:
Max Zhao 2020-03-18 20:40:12 +08:00 committed by GitHub
parent 10e1cc332a
commit 033b0ec159
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 22 deletions

View File

@ -223,7 +223,7 @@ start_rules() {
else else
proxyport="-m multiport --dports 22,53,587,465,995,993,143,80,443" proxyport="-m multiport --dports 22,53,587,465,995,993,143,80,443"
fi fi
if [ "$NETFLIX_SERVER" != "same" ]; then if [ "$NETFLIX_SERVER" != "$GLOBAL_SERVER" ]; then
netflix="1" netflix="1"
else else
netflix="0" netflix="0"
@ -398,7 +398,7 @@ start_redir() {
echo "$(date "+%Y-%m-%d %H:%M:%S") Network Tunnel REDIRECT $threads Threads Started!" >>/tmp/ssrplus.log echo "$(date "+%Y-%m-%d %H:%M:%S") Network Tunnel REDIRECT $threads Threads Started!" >>/tmp/ssrplus.log
fi fi
if [ "$NETFLIX_SERVER" != "same" ]; then if [ "$NETFLIX_SERVER" != "$GLOBAL_SERVER" ]; then
if [ "$ntype" == "ss" -o "$ntype" == "ssr" ]; then if [ "$ntype" == "ss" -o "$ntype" == "ssr" ]; then
gen_config_file $NETFLIX_SERVER 2 4321 gen_config_file $NETFLIX_SERVER 2 4321
gen_config_file $NETFLIX_SERVER 3 1088 gen_config_file $NETFLIX_SERVER 3 1088
@ -592,7 +592,7 @@ rules() {
[ "$GLOBAL_SERVER" == "nil" ] && return 1 [ "$GLOBAL_SERVER" == "nil" ] && return 1
mkdir -p /var/run /var/etc mkdir -p /var/run /var/etc
UDP_RELAY_SERVER=$(uci_get_by_type global udp_relay_server) UDP_RELAY_SERVER=$(uci_get_by_type global udp_relay_server)
[ "$UDP_RELAY_SERVER" == "same" ] && UDP_RELAY_SERVER=$GLOBAL_SERVER [ "$UDP_RELAY_SERVER" == "$GLOBAL_SERVER" ] && UDP_RELAY_SERVER=$GLOBAL_SERVER
if start_rules; then if start_rules; then
return 0 return 0
else else
@ -630,24 +630,26 @@ start() {
fi fi
/usr/share/shadowsocksr/gfw2ipset.sh /usr/share/shadowsocksr/gfw2ipset.sh
if [ "$NETFLIX_SERVER" != "same" ]; then if [ "$NETFLIX_SERVER" != "$GLOBAL_SERVER" ]; then
cat /etc/config/netflix.list | while read line || [ -n "$line" ]; cat /etc/config/netflix.list | while read line || [ -n "$line" ];
do do
sed -i "/$line/d" /tmp/dnsmasq.ssr/gfw_list.conf sed -i "/$line/d" /tmp/dnsmasq.ssr/gfw_list.conf
done done
awk '!/^$/&&!/^#/{printf("ipset=/.%s/'"netflix"'\n",$0)}' /etc/config/netflix.list > /tmp/dnsmasq.ssr/netflix_forward.conf awk '!/^$/&&!/^#/{printf("ipset=/.%s/'"netflix"'\n",$0)}' /etc/config/netflix.list > /tmp/dnsmasq.ssr/netflix_forward.conf
awk '!/^$/&&!/^#/{printf("server=/.%s/'"127.0.0.1#5555"'\n",$0)}' /etc/config/netflix.list >> /tmp/dnsmasq.ssr/netflix_forward.conf awk '!/^$/&&!/^#/{printf("server=/.%s/'"127.0.0.1#5555"'\n",$0)}' /etc/config/netflix.list >> /tmp/dnsmasq.ssr/netflix_forward.conf
ipset -N netflix hash:net 2>/dev/null ipset add ss_spec_wan_ac $(check_host $(uci_get_by_name $NETFLIX_SERVER server)) 2>/dev/null
cat /etc/config/netflixip.list | while read nip || [ -n "$nip" ]; else
do awk '!/^$/&&!/^#/{printf("ipset=/.%s/'"netflix"'\n",$0)}' /etc/config/netflix.list > /tmp/dnsmasq.ssr/netflix_forward.conf
ipset add netflix $nip 2>/dev/null awk '!/^$/&&!/^#/{printf("server=/.%s/'"127.0.0.1#5335"'\n",$0)}' /etc/config/netflix.list >> /tmp/dnsmasq.ssr/netflix_forward.conf
done
ipset add ss_spec_wan_ac $(check_host $(uci_get_by_name $NETFLIX_SERVER server)) 2>/dev/null fi
else
rm -f /tmp/dnsmasq.ssr/netflix_forward.conf ipset -N netflix hash:net 2>/dev/null
fi cat /etc/config/netflixip.list | while read nip || [ -n "$nip" ];
do
ipset add netflix $nip 2>/dev/null
done
/etc/init.d/dnsmasq restart >/dev/null 2>&1 /etc/init.d/dnsmasq restart >/dev/null 2>&1
fi fi
@ -723,3 +725,4 @@ stop() {
fi fi
del_cron del_cron
} }

View File

@ -121,7 +121,9 @@ ipset_r() {
for ip in $WAN_FW_IP; do ipset -! add blacklist $ip; done for ip in $WAN_FW_IP; do ipset -! add blacklist $ip; done
if [ "$NETFLIX" == "1" ]; then if [ "$NETFLIX" == "1" ]; then
$IPT -I SS_SPEC_WAN_AC -p tcp -m set --match-set netflix dst -j REDIRECT --to-ports 4321 $IPT -I SS_SPEC_WAN_AC -p tcp -m set --match-set netflix dst -j REDIRECT --to-ports 4321
else
$IPT -I SS_SPEC_WAN_AC -p tcp -m set --match-set netflix dst -j REDIRECT --to-ports $local_port
fi fi
return $? return $?
} }