luci-app-ssr-plus: sync with upstream source
This commit is contained in:
parent
f7aca1e40a
commit
287c4f72c4
@ -99,7 +99,7 @@ function refresh_data()
|
||||
if type == "gfw_data" or type == "ad_data" then
|
||||
luci.sys.exec("/usr/share/shadowsocksr/gfw2ipset.sh")
|
||||
else
|
||||
luci.sys.exec("/etc/init.d/shadowsocksr restart &")
|
||||
luci.sys.exec("/usr/share/shadowsocksr/chinaipset.sh /tmp/etc/china_ssr.txt")
|
||||
end
|
||||
end
|
||||
else
|
||||
@ -111,7 +111,7 @@ function refresh_data()
|
||||
update(uci:get_first("shadowsocksr", "global", "gfwlist_url", "https://cdn.jsdelivr.net/gh/gfwlist/gfwlist/gfwlist.txt"), "/etc/ssr/gfw_list.conf", set, "/tmp/dnsmasq.ssr/gfw_list.conf")
|
||||
end
|
||||
if set == "ip_data" then
|
||||
update(uci:get_first("shadowsocksr", "global", "chnroute_url","https://ispip.clang.cn/all_cn.txt"), "/etc/ssr/china_ssr.txt", set)
|
||||
update(uci:get_first("shadowsocksr", "global", "chnroute_url","https://ispip.clang.cn/all_cn.txt"), "/etc/ssr/china_ssr.txt", set, "/tmp/etc/china_ssr.txt")
|
||||
end
|
||||
if set == "ad_data" then
|
||||
update(uci:get_first("shadowsocksr", "global", "adblock_url","https://easylist-downloads.adblockplus.org/easylistchina+easylist.txt"), "/etc/ssr/ad.conf", set, "/tmp/dnsmasq.ssr/ad.conf")
|
||||
|
||||
@ -63,14 +63,10 @@ uci_get_by_cfgid() {
|
||||
|
||||
get_host_ip() {
|
||||
local host=$1
|
||||
local isip=""
|
||||
local ip=$host
|
||||
isip=$(echo $host | grep -E "([0-9]{1,3}[\.]){3}[0-9]{1,3}")
|
||||
if [ -z "$isip" ]; then
|
||||
if [ "$host" != "${host#*:[0-9a-fA-F]}" ]; then
|
||||
ip=$host
|
||||
else
|
||||
local ip=$(resolveip -4 -t 3 $host | awk 'NR==1{print}')
|
||||
local ip=$1
|
||||
if [ -z "$(echo $1 | grep -E "([0-9]{1,3}[\.]){3}[0-9]{1,3}")" ]; then
|
||||
if [ "$1" == "${1#*:[0-9a-fA-F]}" ]; then
|
||||
ip=$(resolveip -4 -t 3 $1 | awk 'NR==1{print}')
|
||||
[ -z "$ip" ] && ip=$(wget -q -O- http://119.29.29.29/d?dn=$1 | awk -F ';' '{print $1}')
|
||||
fi
|
||||
fi
|
||||
@ -133,9 +129,8 @@ gen_config_file() {
|
||||
else
|
||||
uci_set_by_name $1 ip $hostip
|
||||
fi
|
||||
[ "$2" == "0" -a "$kcp_flag" == "1" ] && hostip="127.0.0.1"
|
||||
case "$2" in
|
||||
0) config_file=$CONFIG_FILE ;;
|
||||
0) config_file=$CONFIG_FILE && [ "$kcp_flag" == "1" ] && hostip="127.0.0.1" ;;
|
||||
1) config_file=$CONFIG_UDP_FILE ;;
|
||||
2) config_file=$CONFIG_NETFLIX_FILE ;;
|
||||
*) config_file=$CONFIG_SOCK5_FILE ;;
|
||||
@ -302,21 +297,23 @@ start_dns() {
|
||||
EOF
|
||||
/usr/sbin/pdnsd -c /var/etc/pdnsd.conf >/dev/null 2>&1 &
|
||||
}
|
||||
if [ "$ssr_dns" != "0" ]; then
|
||||
ipset_add_dns() {
|
||||
case "$run_mode" in
|
||||
gfw) ipset add gfwlist $dnsserver 2>/dev/null ;;
|
||||
oversea) ipset add oversea $dnsserver 2>/dev/null ;;
|
||||
*) ipset add ss_spec_wan_ac $dnsserver nomatch 2>/dev/null ;;
|
||||
esac
|
||||
fi
|
||||
}
|
||||
case "$ssr_dns" in
|
||||
1)
|
||||
start_pdnsd $dnsserver $dnsport
|
||||
ipset_add_dns
|
||||
pdnsd_enable_flag=1
|
||||
;;
|
||||
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 &
|
||||
ipset_add_dns
|
||||
pdnsd_enable_flag=2
|
||||
;;
|
||||
esac
|
||||
@ -684,8 +681,8 @@ start_rules() {
|
||||
2) echo "-m multiport --dports 22,53,587,465,995,993,143,80,443,853" ;;
|
||||
esac
|
||||
}
|
||||
run_mode=$(uci_get_by_type global run_mode router)
|
||||
get_mode() {
|
||||
run_mode=$(uci_get_by_type global run_mode router)
|
||||
case "$run_mode" in
|
||||
gfw) echo "-g" ;;
|
||||
router) echo "-r" ;;
|
||||
@ -767,8 +764,10 @@ start() {
|
||||
}
|
||||
|
||||
boot() {
|
||||
echo "$(date "+%Y-%m-%d %H:%M:%S") boot!" >/tmp/ssrplus.log
|
||||
ulimit -n 65535
|
||||
(/usr/share/shadowsocksr/chinaipset.sh && sleep 3 && start >/dev/null 2>&1) &
|
||||
/usr/share/shadowsocksr/chinaipset.sh
|
||||
start >/dev/null 2>&1
|
||||
}
|
||||
|
||||
stop() {
|
||||
|
||||
0
package/lean/luci-app-ssr-plus/root/etc/uci-defaults/luci-ssr-plus
Normal file → Executable file
0
package/lean/luci-app-ssr-plus/root/etc/uci-defaults/luci-ssr-plus
Normal file → Executable file
@ -87,12 +87,14 @@ ipset_r() {
|
||||
$IPT -I SS_SPEC_WAN_AC -p tcp ! --dport 53 -d $server -j RETURN
|
||||
case "$RUNMODE" in
|
||||
router)
|
||||
set_china_ip
|
||||
ipset -! -R <<-EOF || return 1
|
||||
create ss_spec_wan_ac hash:net
|
||||
$(gen_iplist | sed -e "s/^/add ss_spec_wan_ac /")
|
||||
EOF
|
||||
ipset -N gfwlist hash:net 2>/dev/null
|
||||
$IPT -A SS_SPEC_WAN_AC -m set --match-set ss_spec_wan_ac dst -j RETURN
|
||||
$IPT -A SS_SPEC_WAN_AC -m set --match-set china dst -j RETURN
|
||||
$IPT -A SS_SPEC_WAN_AC -j SS_SPEC_WAN_FW
|
||||
;;
|
||||
gfw)
|
||||
@ -280,10 +282,13 @@ gen_iplist() {
|
||||
240.0.0.0/4
|
||||
255.255.255.255
|
||||
$(get_wan_ip)
|
||||
$(cat ${IGNORE_LIST:=/dev/null} 2>/dev/null)
|
||||
EOF
|
||||
}
|
||||
|
||||
set_china_ip() {
|
||||
[ -f "$IGNORE_LIST" ] && /usr/share/shadowsocksr/chinaipset.sh $IGNORE_LIST
|
||||
}
|
||||
|
||||
gen_spec_iplist() {
|
||||
cat <<-EOF
|
||||
0.0.0.0/8
|
||||
|
||||
@ -38,14 +38,10 @@ CURRENT_SERVER=$DEFAULT_SERVER
|
||||
#解析ip
|
||||
get_host_ip() {
|
||||
local host=$1
|
||||
local isip=""
|
||||
local ip=$host
|
||||
isip=$(echo $host | grep -E "([0-9]{1,3}[\.]){3}[0-9]{1,3}")
|
||||
if [ -z "$isip" ]; then
|
||||
if [ "$host" != "${host#*:[0-9a-fA-F]}" ]; then
|
||||
ip=$host
|
||||
else
|
||||
local ip=$(resolveip -4 -t 3 $host | awk 'NR==1{print}')
|
||||
local ip=$1
|
||||
if [ -z "$(echo $1 | grep -E "([0-9]{1,3}[\.]){3}[0-9]{1,3}")" ]; then
|
||||
if [ "$1" == "${1#*:[0-9a-fA-F]}" ]; then
|
||||
ip=$(resolveip -4 -t 3 $1 | awk 'NR==1{print}')
|
||||
[ -z "$ip" ] && ip=$(wget -q -O- http://119.29.29.29/d?dn=$1 | awk -F ';' '{print $1}')
|
||||
fi
|
||||
fi
|
||||
|
||||
@ -1,9 +1,11 @@
|
||||
#!/bin/sh
|
||||
LOCK_FILE="/var/lock/ssr-chinaipset.lock"
|
||||
[ -f "$LOCK_FILE" ] && exit 2
|
||||
[ -f "$1" ] && china_ip=$1
|
||||
touch "$LOCK_FILE"
|
||||
echo "create china hash:net family inet hashsize 1024 maxelem 65536" >/tmp/china.ipset
|
||||
awk '!/^$/&&!/^#/{printf("add china %s'" "'\n",$0)}' /etc/ssr/china_ssr.txt >>/tmp/china.ipset
|
||||
ipset -! flush china
|
||||
ipset -! restore </tmp/china.ipset 2>/dev/null
|
||||
rm -f /tmp/china.ipset $LOCK_FILE
|
||||
ipset -! flush china 2>/dev/null
|
||||
ipset -! -R <<-EOF || rm -f $LOCK_FILE && exit 1
|
||||
create china hash:net
|
||||
$(cat ${china_ip:=/etc/ssr/china_ssr.txt} | sed -e "s/^/add china /")
|
||||
EOF
|
||||
rm -f $LOCK_FILE
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
/usr/bin/lua /usr/share/shadowsocksr/update.lua
|
||||
sleep 2s
|
||||
/usr/share/shadowsocksr/chinaipset.sh
|
||||
/usr/share/shadowsocksr/chinaipset.sh /tmp/etc/china_ssr.txt
|
||||
sleep 2s
|
||||
/usr/bin/lua /usr/share/shadowsocksr/subscribe.lua
|
||||
|
||||
@ -42,7 +42,7 @@ end
|
||||
log("正在更新【GFW列表】数据库")
|
||||
update(uci:get_first("shadowsocksr", "global", "gfwlist_url", "https://cdn.jsdelivr.net/gh/v2fly/domain-list-community@release/gfwlist.txt"), "/etc/ssr/gfw_list.conf", "gfw_data", "/tmp/dnsmasq.ssr/gfw_list.conf")
|
||||
log("正在更新【国内IP段】数据库")
|
||||
update(uci:get_first("shadowsocksr", "global", "chnroute_url","https://ispip.clang.cn/all_cn.txt"), "/etc/ssr/china_ssr.txt", "cnip")
|
||||
update(uci:get_first("shadowsocksr", "global", "chnroute_url","https://ispip.clang.cn/all_cn.txt"), "/etc/ssr/china_ssr.txt", "cnip", "/tmp/etc/china_ssr.txt")
|
||||
if uci:get_first("shadowsocksr", "global", "adblock","0") == "1" then
|
||||
log("正在更新【广告屏蔽】数据库")
|
||||
update(uci:get_first("shadowsocksr", "global", "adblock_url","https://easylist-downloads.adblockplus.org/easylistchina+easylist.txt"), "/etc/ssr/ad.conf", "ad_data", "/tmp/dnsmasq.ssr/ad.conf")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user