diff --git a/package/lean/luci-app-ssr-plus/Makefile b/package/lean/luci-app-ssr-plus/Makefile index 29cf30e94..24711c76a 100644 --- a/package/lean/luci-app-ssr-plus/Makefile +++ b/package/lean/luci-app-ssr-plus/Makefile @@ -2,7 +2,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-ssr-plus PKG_VERSION:=169 -PKG_RELEASE:=6 +PKG_RELEASE:=7 PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME) diff --git a/package/lean/luci-app-ssr-plus/root/etc/init.d/shadowsocksr b/package/lean/luci-app-ssr-plus/root/etc/init.d/shadowsocksr index 1a9cd67ca..4bec94194 100755 --- a/package/lean/luci-app-ssr-plus/root/etc/init.d/shadowsocksr +++ b/package/lean/luci-app-ssr-plus/root/etc/init.d/shadowsocksr @@ -47,6 +47,23 @@ uci_get_by_cfgid() { echo ${ret:=$3} } +check_host() { + local host=$1 + if echo $host | grep -E "^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$" >/dev/null; then + hostip=$host + elif [ "$host" != "${host#*:[0-9a-fA-F]}" ]; then + hostip=$host + else + hostip=$(ping $host -W 1 -s 1 -c 1 | grep PING | cut -d'(' -f 2 | cut -d')' -f1) + if echo $hostip | grep -E "^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$" >/dev/null; then + hostip=$hostip + else + hostip="127.0.0.1" + fi + fi + echo -e $hostip +} + add_cron() { sed -i '/shadowsocksr/d' $CRON_FILE sed -i '/ssrplus.log/d' $CRON_FILE && echo '0 1 * * * echo "" > /tmp/ssrplus.log' >>$CRON_FILE @@ -451,7 +468,7 @@ start_redir() { local dnsstr="$(uci_get_by_type global tunnel_forward 8.8.4.4:53)" local dnsserver=$(echo "$dnsstr" | awk -F ':' '{print $1}') local dnsport=$(echo "$dnsstr" | awk -F ':' '{print $2}') - if [ "$ssr_dns" != "0" ]; then # not use custom dns service + if [ "$ssr_dns" != "0" ]; then if [ "$run_mode" == "gfw" ]; then ipset add gfwlist $dnsserver 2>/dev/null elif [ "$run_mode" == "oversea" ]; then @@ -459,14 +476,12 @@ start_redir() { else ipset add ss_spec_wan_ac $dnsserver nomatch 2>/dev/null fi - fi - if [ "$ssr_dns" == "1" ]; then start_pdnsd $dnsserver $dnsport pdnsd_enable_flag=1 elif [ "$ssr_dns" == "2" ]; then - microsocks -i 127.0.0.1 -p 10802 ssr-dns >/dev/null 2>&1 & - dns2socks 127.0.0.1:10802 $dnsserver:$dnsport 127.0.0.1:5335 -q >/dev/null 2>&1 & - pdnsd_enable_flag=2 + microsocks -i 127.0.0.1 -p 10802 ssr-dns >/dev/null 2>&1 & + dns2socks 127.0.0.1:10802 $dnsserver:$dnsport 127.0.0.1:5335 -q >/dev/null 2>&1 & + pdnsd_enable_flag=2 fi if [ "$(uci_get_by_type global enable_switch)" == "1" ]; then if [ "$(uci_get_by_name $GLOBAL_SERVER switch_enable 1)" == "1" ]; then @@ -620,6 +635,8 @@ start() { done 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 + + ipset add ss_spec_wan_ac $(check_host $(uci_get_by_name $NETFLIX_SERVER server)) 2>/dev/null else rm -f /tmp/dnsmasq.ssr/netflix_forward.conf fi @@ -698,4 +715,3 @@ stop() { fi del_cron } -