mirror of
https://github.com/fw876/helloworld.git
synced 2026-12-06 00:01:06 +00:00
Merge pull request #162 from Mattraks/develop
Optimizing DNSmasq processing
This commit is contained in:
9 files changed
+78
-21
No files matched your search
@@ -2,7 +2,7 @@ include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=luci-app-ssr-plus
|
||||
PKG_VERSION:=180
|
||||
PKG_RELEASE:=5
|
||||
PKG_RELEASE:=6
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
|
||||
@@ -97,7 +97,7 @@ function refresh_data()
|
||||
if file2 then luci.sys.exec("cp -f /tmp/ssr-update." .. type .. " " .. file2) end
|
||||
retstring = tostring(tonumber(icount)/Num)
|
||||
if type == "gfw_data" or type == "ad_data" then
|
||||
luci.sys.exec("/usr/share/shadowsocksr/gfw2ipset.sh gfw_data")
|
||||
luci.sys.exec("/usr/share/shadowsocksr/gfw2ipset.sh")
|
||||
else
|
||||
luci.sys.exec("/etc/init.d/shadowsocksr restart &")
|
||||
end
|
||||
|
||||
@@ -50,6 +50,7 @@ o.rmempty = false
|
||||
|
||||
o = s:option(Value, "adblock_url", translate("adblock_url"))
|
||||
o:value("https://anti-ad.net/anti-ad-for-dnsmasq.conf", translate("anti-AD"))
|
||||
o:value("https://easylist-downloads.adblockplus.org/easylistchina+easylist.txt", translate("Easylist China"))
|
||||
o.default = "https://anti-ad.net/anti-ad-for-dnsmasq.conf"
|
||||
o:depends("adblock", "1")
|
||||
o.description = translate("Support AdGuardHome and DNSMASQ format list")
|
||||
|
||||
@@ -700,10 +700,6 @@ start() {
|
||||
cat <<-EOF >/tmp/dnsmasq.d/dnsmasq-ssr.conf
|
||||
conf-dir=/tmp/dnsmasq.ssr
|
||||
EOF
|
||||
if [ "$(uci_get_by_type global adblock 0)" == "1" ]; then
|
||||
cp -rf /etc/ssr/ad.conf /tmp/dnsmasq.ssr/
|
||||
awk '!/^$/&&!/^#/{printf("address=/%s/''\n",$0)}' /etc/ssr/deny.list >/tmp/dnsmasq.ssr/denylist.conf
|
||||
fi
|
||||
if rules; then
|
||||
if start_redir_tcp; then
|
||||
start_redir_udp
|
||||
@@ -717,10 +713,20 @@ start() {
|
||||
cp -rf /etc/ssr/gfw_list.conf /tmp/dnsmasq.ssr/
|
||||
cp -rf /etc/ssr/gfw_base.conf /tmp/dnsmasq.ssr/
|
||||
fi
|
||||
/usr/share/shadowsocksr/gfw2ipset.sh
|
||||
/usr/share/shadowsocksr/gfw2ipset.sh $switch_server
|
||||
else
|
||||
/usr/bin/ssr-rules -f
|
||||
fi
|
||||
else
|
||||
awk '!/^$/&&!/^#/{printf("address=/%s/''\n",$0)}' /etc/ssr/deny.list >/tmp/dnsmasq.ssr/denylist.conf
|
||||
if [ "$(uci_get_by_type global adblock 0)" == "1" ]; then
|
||||
[ "$1" == "" ] && cp -f /etc/ssr/ad.conf /tmp/dnsmasq.ssr/
|
||||
if [ -f "/tmp/dnsmasq.ssr/ad.conf" ]; then
|
||||
for line in $(cat /etc/ssr/black.list); do sed -i "/$line/d" /tmp/dnsmasq.ssr/ad.conf; done
|
||||
for line in $(cat /etc/ssr/white.list); do sed -i "/$line/d" /tmp/dnsmasq.ssr/ad.conf; done
|
||||
for line in $(cat /etc/ssr/deny.list); do sed -i "/$line/d" /tmp/dnsmasq.ssr/ad.conf; done
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
/etc/init.d/dnsmasq restart >/dev/null 2>&1
|
||||
start_server
|
||||
|
||||
@@ -3902,7 +3902,6 @@
|
||||
103.139.212.0/23
|
||||
103.140.8.0/23
|
||||
103.140.14.0/23
|
||||
103.140.46.0/23
|
||||
103.140.70.0/23
|
||||
103.140.126.0/23
|
||||
103.140.140.0/23
|
||||
@@ -4074,6 +4073,14 @@
|
||||
103.154.32.0/23
|
||||
103.154.40.0/23
|
||||
103.154.66.0/23
|
||||
103.154.162.0/23
|
||||
103.154.164.0/23
|
||||
103.154.168.0/23
|
||||
103.154.242.0/23
|
||||
103.155.14.0/23
|
||||
103.155.16.0/23
|
||||
103.155.34.0/23
|
||||
103.155.48.0/23
|
||||
103.192.0.0/22
|
||||
103.192.4.0/22
|
||||
103.192.8.0/22
|
||||
|
||||
@@ -1816,6 +1816,8 @@ server=/community.windy.com/127.0.0.1#5335
|
||||
ipset=/community.windy.com/gfwlist
|
||||
server=/communitychoicecu.com/127.0.0.1#5335
|
||||
ipset=/communitychoicecu.com/gfwlist
|
||||
server=/comparitech.com/127.0.0.1#5335
|
||||
ipset=/comparitech.com/gfwlist
|
||||
server=/compileheart.com/127.0.0.1#5335
|
||||
ipset=/compileheart.com/gfwlist
|
||||
server=/compress.to/127.0.0.1#5335
|
||||
@@ -1910,6 +1912,8 @@ server=/ctao.org/127.0.0.1#5335
|
||||
ipset=/ctao.org/gfwlist
|
||||
server=/ctfriend.net/127.0.0.1#5335
|
||||
ipset=/ctfriend.net/gfwlist
|
||||
server=/cthlo.github.io/127.0.0.1#5335
|
||||
ipset=/cthlo.github.io/gfwlist
|
||||
server=/ctitv.com.tw/127.0.0.1#5335
|
||||
ipset=/ctitv.com.tw/gfwlist
|
||||
server=/cts.com.tw/127.0.0.1#5335
|
||||
@@ -1984,6 +1988,8 @@ server=/daidostup.ru/127.0.0.1#5335
|
||||
ipset=/daidostup.ru/gfwlist
|
||||
server=/dailidaili.com/127.0.0.1#5335
|
||||
ipset=/dailidaili.com/gfwlist
|
||||
server=/dailymail.co.uk/127.0.0.1#5335
|
||||
ipset=/dailymail.co.uk/gfwlist
|
||||
server=/dailymotion.com/127.0.0.1#5335
|
||||
ipset=/dailymotion.com/gfwlist
|
||||
server=/dailyview.tw/127.0.0.1#5335
|
||||
@@ -3666,6 +3672,8 @@ server=/googlebot.com/127.0.0.1#5335
|
||||
ipset=/googlebot.com/gfwlist
|
||||
server=/googlechinawebmaster.com/127.0.0.1#5335
|
||||
ipset=/googlechinawebmaster.com/gfwlist
|
||||
server=/googlechrome.github.io/127.0.0.1#5335
|
||||
ipset=/googlechrome.github.io/gfwlist
|
||||
server=/googlecode.com/127.0.0.1#5335
|
||||
ipset=/googlecode.com/gfwlist
|
||||
server=/googlecommerce.com/127.0.0.1#5335
|
||||
@@ -4640,6 +4648,8 @@ server=/ixxx.com/127.0.0.1#5335
|
||||
ipset=/ixxx.com/gfwlist
|
||||
server=/iyouport.com/127.0.0.1#5335
|
||||
ipset=/iyouport.com/gfwlist
|
||||
server=/iyouport.org/127.0.0.1#5335
|
||||
ipset=/iyouport.org/gfwlist
|
||||
server=/izaobao.us/127.0.0.1#5335
|
||||
ipset=/izaobao.us/gfwlist
|
||||
server=/izles.net/127.0.0.1#5335
|
||||
@@ -6130,6 +6140,8 @@ server=/nylon-angel.com/127.0.0.1#5335
|
||||
ipset=/nylon-angel.com/gfwlist
|
||||
server=/nylonstockingsonline.com/127.0.0.1#5335
|
||||
ipset=/nylonstockingsonline.com/gfwlist
|
||||
server=/nypost.com/127.0.0.1#5335
|
||||
ipset=/nypost.com/gfwlist
|
||||
server=/nyt.com/127.0.0.1#5335
|
||||
ipset=/nyt.com/gfwlist
|
||||
server=/nytchina.com/127.0.0.1#5335
|
||||
@@ -7062,6 +7074,8 @@ server=/robustnessiskey.com/127.0.0.1#5335
|
||||
ipset=/robustnessiskey.com/gfwlist
|
||||
server=/rocket-inc.net/127.0.0.1#5335
|
||||
ipset=/rocket-inc.net/gfwlist
|
||||
server=/rocketcdn.me/127.0.0.1#5335
|
||||
ipset=/rocketcdn.me/gfwlist
|
||||
server=/rocksdb.org/127.0.0.1#5335
|
||||
ipset=/rocksdb.org/gfwlist
|
||||
server=/rojo.com/127.0.0.1#5335
|
||||
@@ -7782,6 +7796,8 @@ server=/stumbleupon.com/127.0.0.1#5335
|
||||
ipset=/stumbleupon.com/gfwlist
|
||||
server=/stupidvideos.com/127.0.0.1#5335
|
||||
ipset=/stupidvideos.com/gfwlist
|
||||
server=/stweetly.com/127.0.0.1#5335
|
||||
ipset=/stweetly.com/gfwlist
|
||||
server=/subacme.rerouted.org/127.0.0.1#5335
|
||||
ipset=/subacme.rerouted.org/gfwlist
|
||||
server=/successfn.com/127.0.0.1#5335
|
||||
@@ -8102,6 +8118,8 @@ server=/themoviedb.org/127.0.0.1#5335
|
||||
ipset=/themoviedb.org/gfwlist
|
||||
server=/thenewslens.com/127.0.0.1#5335
|
||||
ipset=/thenewslens.com/gfwlist
|
||||
server=/thepiratebay.ee/127.0.0.1#5335
|
||||
ipset=/thepiratebay.ee/gfwlist
|
||||
server=/thepiratebay.org/127.0.0.1#5335
|
||||
ipset=/thepiratebay.org/gfwlist
|
||||
server=/theporndude.com/127.0.0.1#5335
|
||||
@@ -9996,6 +10014,8 @@ server=/youdontcare.com/127.0.0.1#5335
|
||||
ipset=/youdontcare.com/gfwlist
|
||||
server=/youjizz.com/127.0.0.1#5335
|
||||
ipset=/youjizz.com/gfwlist
|
||||
server=/youlucky.com/127.0.0.1#5335
|
||||
ipset=/youlucky.com/gfwlist
|
||||
server=/youmaker.com/127.0.0.1#5335
|
||||
ipset=/youmaker.com/gfwlist
|
||||
server=/youngpornvideos.com/127.0.0.1#5335
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
#!/bin/sh -e
|
||||
if [ -f /tmp/adnew.conf ]; then
|
||||
if (grep -wq "address=" /tmp/adnew.conf); then
|
||||
cp /tmp/adnew.conf /tmp/ssr-update.$1
|
||||
if [ -f /tmp/ssr-update.$1 ]; then
|
||||
if (grep -wq "address=" /tmp/ssr-update.$1); then
|
||||
return $?
|
||||
else
|
||||
cp /tmp/ssr-update.$1 /tmp/adnew.conf
|
||||
cat /tmp/adnew.conf | grep ^\|\|[^\*]*\^$ | sed -e 's:||:address\=\/:' -e 's:\^:/0\.0\.0\.0:' >/tmp/ssr-update.$1
|
||||
rm -f /tmp/adnew.conf
|
||||
fi
|
||||
fi
|
||||
rm -f /tmp/adnew.conf
|
||||
@@ -126,7 +126,7 @@ ipset_r() {
|
||||
$IPT -I SS_SPEC_WAN_AC -m set --match-set blacklist dst -j SS_SPEC_WAN_FW
|
||||
$IPT -I SS_SPEC_WAN_AC -m set --match-set whitelist dst -j RETURN
|
||||
if [ $(ipset list music -name -quiet | grep music) ]; then
|
||||
$IPT -I SS_SPEC_WAN_AC -m set --match-set music dst -j RETURN 2>/dev/null
|
||||
$IPT -I SS_SPEC_WAN_AC -m set --match-set music dst -j RETURN 2>/dev/null
|
||||
fi
|
||||
for ip in $WAN_BP_IP; do ipset -! add whitelist $ip; done
|
||||
for ip in $WAN_FW_IP; do ipset -! add blacklist $ip; done
|
||||
@@ -143,7 +143,9 @@ ipset_r() {
|
||||
ipset -! add whitelist $NETFLIX_IP
|
||||
fi
|
||||
;;
|
||||
2) $IPT -I SS_SPEC_WAN_AC -p tcp -m set --match-set netflix dst -j REDIRECT --to-ports $local_port ;;
|
||||
2)
|
||||
$IPT -I SS_SPEC_WAN_AC -p tcp -m set --match-set netflix dst -j REDIRECT --to-ports $local_port
|
||||
;;
|
||||
esac
|
||||
return $?
|
||||
}
|
||||
|
||||
@@ -1,19 +1,25 @@
|
||||
#!/bin/sh
|
||||
NAME=shadowsocksr
|
||||
switch_server=$1
|
||||
uci_get_by_type() {
|
||||
local ret=$(uci get $NAME.@$1[0].$2 2>/dev/null)
|
||||
echo ${ret:=$3}
|
||||
}
|
||||
GLOBAL_SERVER=$(uci_get_by_type global global_server)
|
||||
if [ -z "$switch_server" ]; then
|
||||
GLOBAL_SERVER=$(uci_get_by_type global global_server nil)
|
||||
else
|
||||
GLOBAL_SERVER=$switch_server
|
||||
fi
|
||||
NETFLIX_SERVER=$(uci_get_by_type global netflix_server nil)
|
||||
[ "$NETFLIX_SERVER" == "same" ] && NETFLIX_SERVER=$GLOBAL_SERVER
|
||||
if [ "$NETFLIX_SERVER" != "nil" ]; then
|
||||
netflix() {
|
||||
if [ -f "/tmp/dnsmasq.ssr/gfw_list.conf" ]; then
|
||||
for line in $(cat /etc/ssr/netflix.list); do sed -i "/$line/d" /tmp/dnsmasq.ssr/gfw_list.conf; done
|
||||
for line in $(cat /etc/ssr/netflix.list); do sed -i "/$line/d" /tmp/dnsmasq.ssr/gfw_base.conf; done
|
||||
fi
|
||||
awk '!/^$/&&!/^#/{printf("ipset=/.%s/'"netflix"'\n",$0)}' /etc/ssr/netflix.list >/tmp/dnsmasq.ssr/netflix_forward.conf
|
||||
awk '!/^$/&&!/^#/{printf("server=/.%s/'"127.0.0.1#$1"'\n",$0)}' /etc/ssr/netflix.list >>/tmp/dnsmasq.ssr/netflix_forward.conf
|
||||
awk '!/^$/&&!/^#/{printf("ipset=/%s/'"netflix"'\n",$0)}' /etc/ssr/netflix.list >/tmp/dnsmasq.ssr/netflix_forward.conf
|
||||
awk '!/^$/&&!/^#/{printf("server=/%s/'"127.0.0.1#$1"'\n",$0)}' /etc/ssr/netflix.list >>/tmp/dnsmasq.ssr/netflix_forward.conf
|
||||
}
|
||||
if [ "$NETFLIX_SERVER" != "$GLOBAL_SERVER" ]; then
|
||||
netflix 5555
|
||||
@@ -23,8 +29,22 @@ if [ "$NETFLIX_SERVER" != "nil" ]; then
|
||||
else
|
||||
rm -f /tmp/dnsmasq.ssr/netflix_forward.conf
|
||||
fi
|
||||
if [ "$1" == "" ]; then
|
||||
awk '!/^$/&&!/^#/{printf("ipset=/.%s/'"blacklist"'\n",$0)}' /etc/ssr/black.list >/tmp/dnsmasq.ssr/blacklist_forward.conf
|
||||
awk '!/^$/&&!/^#/{printf("server=/.%s/'"127.0.0.1#5335"'\n",$0)}' /etc/ssr/black.list >>/tmp/dnsmasq.ssr/blacklist_forward.conf
|
||||
awk '!/^$/&&!/^#/{printf("ipset=/.%s/'"whitelist"'\n",$0)}' /etc/ssr/white.list >/tmp/dnsmasq.ssr/whitelist_forward.conf
|
||||
for line in $(cat /etc/ssr/black.list); do sed -i "/$line/d" /tmp/dnsmasq.ssr/gfw_list.conf; done
|
||||
for line in $(cat /etc/ssr/black.list); do sed -i "/$line/d" /tmp/dnsmasq.ssr/gfw_base.conf; done
|
||||
for line in $(cat /etc/ssr/white.list); do sed -i "/$line/d" /tmp/dnsmasq.ssr/gfw_list.conf; done
|
||||
for line in $(cat /etc/ssr/white.list); do sed -i "/$line/d" /tmp/dnsmasq.ssr/gfw_base.conf; done
|
||||
for line in $(cat /etc/ssr/deny.list); do sed -i "/$line/d" /tmp/dnsmasq.ssr/gfw_list.conf; done
|
||||
for line in $(cat /etc/ssr/deny.list); do sed -i "/$line/d" /tmp/dnsmasq.ssr/gfw_base.conf; done
|
||||
awk '!/^$/&&!/^#/{printf("ipset=/%s/'"blacklist"'\n",$0)}' /etc/ssr/black.list >/tmp/dnsmasq.ssr/blacklist_forward.conf
|
||||
awk '!/^$/&&!/^#/{printf("server=/%s/'"127.0.0.1#5335"'\n",$0)}' /etc/ssr/black.list >>/tmp/dnsmasq.ssr/blacklist_forward.conf
|
||||
awk '!/^$/&&!/^#/{printf("ipset=/%s/'"whitelist"'\n",$0)}' /etc/ssr/white.list >/tmp/dnsmasq.ssr/whitelist_forward.conf
|
||||
awk '!/^$/&&!/^#/{printf("address=/%s/''\n",$0)}' /etc/ssr/deny.list >/tmp/dnsmasq.ssr/denylist.conf
|
||||
if [ "$(uci_get_by_type global adblock 0)" == "1" ]; then
|
||||
[ "$1" == "" ] && cp -f /etc/ssr/ad.conf /tmp/dnsmasq.ssr/
|
||||
if [ -f "/tmp/dnsmasq.ssr/ad.conf" ]; then
|
||||
for line in $(cat /etc/ssr/black.list); do sed -i "/$line/d" /tmp/dnsmasq.ssr/ad.conf; done
|
||||
for line in $(cat /etc/ssr/white.list); do sed -i "/$line/d" /tmp/dnsmasq.ssr/ad.conf; done
|
||||
for line in $(cat /etc/ssr/deny.list); do sed -i "/$line/d" /tmp/dnsmasq.ssr/ad.conf; done
|
||||
for line in $(cat /etc/ssr/netflix.list); do sed -i "/$line/d" /tmp/dnsmasq.ssr/ad.conf; done
|
||||
fi
|
||||
fi
|
||||
Reference in new issue
Block a user