Skip to content

Commit a36588a

Browse files
committed
修复LF问题,更新广告规则,解耦合iptables脚本以配合第三方软件实现启停,修改上游DNS为DoT
1 parent 7fc89ae commit a36588a

File tree

8 files changed

+52
-54
lines changed

8 files changed

+52
-54
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
AdguardHome.zip
1+
*.zip

apply_iptables.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
iptables -t nat -N ADGUARD
2+
# 返回所有 AdGuardHome 的请求
3+
iptables -t nat -A ADGUARD -m owner --uid-owner root --gid-owner net_raw -j RETURN
4+
# 将 53 端口所有 udp tcp 流量转发到 adguard home
5+
iptables -t nat -A ADGUARD -p udp --dport 53 -j REDIRECT --to-ports 5591
6+
iptables -t nat -A ADGUARD -p tcp --dport 53 -j REDIRECT --to-ports 5591
7+
# ip6 缺少nat表,待查问题
8+
# ip6tables -t nat -A ADGUARD -p udp --dport 53 -j REDIRECT --to-ports 5591
9+
# ip6tables -t nat -A ADGUARD -p tcp --dport 53 -j REDIRECT --to-ports 5591
10+
# 将 ADGUARD 规则添加到 OUTPUT
11+
iptables -t nat -I OUTPUT 1 -j ADGUARD

bin/AdGuardHome.yaml

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,15 @@ dns:
2323
ratelimit_whitelist: []
2424
refuse_any: true
2525
upstream_dns:
26-
- https://223.5.5.5/dns-query
27-
- https://1.12.12.12/dns-query
26+
- tls://dot.pub
27+
- tls://dns.alidns.com
2828
upstream_dns_file: ""
2929
bootstrap_dns:
30-
- 127.0.0.1
30+
- 223.5.5.5
31+
- 119.29.29.29
3132
fallback_dns:
32-
- https://223.6.6.6/dns-query
33-
- https://120.53.53.53/dns-query
34-
- https://8.8.8.8/dns-query
35-
- https://1.1.1.1/dns-query
33+
- tls://dns.google
34+
- tls://1dot1dot1dot1.cloudflare-dns.com
3635
all_servers: true
3736
fastest_addr: false
3837
fastest_timeout: 1s
@@ -46,8 +45,8 @@ dns:
4645
- 127.0.0.0/8
4746
- ::1/128
4847
cache_size: 33554432
49-
cache_ttl_min: 300
50-
cache_ttl_max: 3600
48+
cache_ttl_min: 0
49+
cache_ttl_max: 0
5150
cache_optimistic: true
5251
bogus_nxdomain: []
5352
aaaa_disabled: false
@@ -101,9 +100,7 @@ filters:
101100
name: 秋风广告规则
102101
id: 1700480708
103102
whitelist_filters: []
104-
user_rules:
105-
- '@@||pglstatp-toutiao.com^$important'
106-
- ""
103+
user_rules: []
107104
dhcp:
108105
enabled: false
109106
interface_name: ""
@@ -137,7 +134,7 @@ filtering:
137134
pixabay: true
138135
yandex: true
139136
youtube: true
140-
blocking_mode: null_ip
137+
blocking_mode: default
141138
parental_block_host: family-block.dns.adguard.com
142139
safebrowsing_block_host: standard-block.dns.adguard.com
143140
rewrites: []
@@ -146,7 +143,7 @@ filtering:
146143
parental_cache_size: 1048576
147144
cache_time: 30
148145
filters_update_interval: 72
149-
blocked_response_ttl: 30
146+
blocked_response_ttl: 10
150147
filtering_enabled: true
151148
parental_enabled: false
152149
safebrowsing_enabled: false

bin/data/filters/1700480708.txt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@
9595
||analytics.pinterest.com^
9696
||analytics.rayjump.com^
9797
||analytics.tiktok.com^
98+
||analytics.woozooo.com^
9899
||analyze.lemurbrowser.com^
99100
||api-access.pangolin-sdk-toutiao*.com^
100101
||api-access.pangolin-sdk-toutiao.com3^
@@ -284,14 +285,17 @@
284285
||mon.snssdk.com^
285286
||monitor.music.qq.com^
286287
||monitor.uu.qq.com^
288+
||mp.weixin.qq.com/mp/getappmsgad^
287289
||mtj.baidu.com^
288290
||nmetrics.samsung.com^
289291
||notes-analytics-events.apple.com^
290292
||nsclick.baidu.com^
291293
||o2o.api.xiaomi.com^
292-
||offerwall.yandex.net^||open.e.kuaishou.cn^
294+
||offerwall.yandex.net^
295+
||open.e.kuaishou.cn^
293296
||open.e.kuaishou.com^
294297
||open.kuaishouzt.com^
298+
||open.kwaishouzt.com^
295299
||open.kwaizt.com^
296300
||optimus-ads.amap.com^
297301
||oth.eve.mdt.qq.com^
@@ -375,7 +379,8 @@
375379
||tdc.qq.com^
376380
||tdid.m.qq.com^
377381
||test.ad.xiaomi.com^
378-
||test.e.ad.xiaomi.com^||tj.b.qq.com^
382+
||test.e.ad.xiaomi.com^
383+
||tj.b.qq.com^
379384
||tj.video.qq.com^
380385
||tmead.y.qq.com^
381386
||tmfsdk.m.qq.com^

customize.sh

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
if [ "$ARCH" != "arm64" ]; then
2-
ui_print "仅支持arm64架构,安装失败"
3-
exit 1
2+
abort "仅支持 arm64 架构,安装失败"
43
fi
54

65
ADG_DIR="$MODPATH/bin"
7-
chmod 777 "$ADG_DIR/AdGuardHome"
6+
chmod +x "$ADG_DIR/AdGuardHome" "$MODPATH/apply_iptables.sh" "$MODPATH/flush_iptables.sh"
87
# TODO: 研究用户组对程序运行有什么影响
9-
chgrp net_raw "$ADG_DIR/AdGuardHome"
10-
chgrp net_raw "$ADG_DIR/AdGuardHome.yaml"
8+
# chgrp net_raw "$ADG_DIR/AdGuardHome"
9+
# chgrp net_raw "$ADG_DIR/AdGuardHome.yaml"
1110

12-
ui_print "安装成功"
11+
ui_print "安装成功,请重启设备"

flush_iptables.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
iptables -t nat -D OUTPUT 1
2+
iptables -t nat -F ADGUARD
3+
iptables -t nat -X ADGUARD
4+
5+
# ip6tables -t nat -D ADGUARD 1
6+
# ip6tables -t nat -F ADGUARD
7+
# ip6tables -t nat -X ADGUARD

module.prop

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
id=AdGuardHome
22
name=AdGuardHome for Magisk
3-
version=20231219
4-
versionCode=7
3+
version=20231223
4+
versionCode=8
55
author=twoone3
66
description=通过DNS层面过滤广告、防DNS劫持,后台地址http://127.0.0.1:3000,用户名/密码root

service.sh

Lines changed: 8 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,12 @@
1-
until [ $(getprop sys.boot_completed) ]; do
2-
sleep 1
3-
done
1+
# until [ $(getprop sys.boot_completed) ]; do
2+
# sleep 1
3+
# done
44
MODDIR="${0%/*}"
55
ADG_DIR="$MODDIR/bin"
6-
setuidgid root:net_raw "$ADG_DIR/AdGuardHome" >"$ADG_DIR/AdGuardHome.log" 2>&1 &
6+
# 输出重定向
7+
exec 1>"$ADG_DIR/stdout.log"
8+
exec 2>"$ADG_DIR/stderr.log"
79

8-
# 读取配置文件的端口
9-
adhome_port="$(cat "$ADG_DIR/AdGuardHome.yaml" | egrep '^ port: ' | sed -n 's/ port: //g;s/ //g;$p')"
10+
setuidgid root:net_raw "$ADG_DIR/AdGuardHome" 2>&1 &
1011

11-
apply_rules() {
12-
# 新建规则链
13-
iptables -t nat -N ADGUARD
14-
# 返回所有 AdGuardHome 的请求
15-
iptables -t nat -A ADGUARD -m owner --uid-owner root --gid-owner net_raw -j RETURN
16-
# 将 53 端口所有 udp tcp 流量转发到 adguard home
17-
iptables -t nat -A ADGUARD -p udp --dport 53 -j REDIRECT --to-ports ${adhome_port}
18-
iptables -t nat -A ADGUARD -p tcp --dport 53 -j REDIRECT --to-ports ${adhome_port}
19-
ip6tables -t nat -A ADGUARD -p udp --dport 53 -j REDIRECT --to-ports ${adhome_port}
20-
ip6tables -t nat -A ADGUARD -p tcp --dport 53 -j REDIRECT --to-ports ${adhome_port}
21-
# 将 ADGUARD 规则添加到 OUTPUT
22-
iptables -t nat -A OUTPUT -j ADGUARD
23-
}
24-
25-
flush_rules() {
26-
iptables -t mangle -F ADGUARD
27-
iptables -t mangle -X ADGUARD
28-
29-
ip6tables -t mangle -F ADGUARD
30-
ip6tables -t mangle -X ADGUARD
31-
}
32-
33-
apply_rules
12+
"$MODDIR/apply_iptables.sh"

0 commit comments

Comments
 (0)