Skip to content

Commit

Permalink
使用更优雅的代理逻辑,更换DNS,解决纯DNS回环问题,提高解析速度,更改AdGuardHome路径
Browse files Browse the repository at this point in the history
  • Loading branch information
twoone-3 committed Dec 18, 2023
1 parent 2ca1009 commit 8c1571d
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 30 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@
![GitHub all releases](https://img.shields.io/github/downloads/twoone-3/AdguardHome/total)

# 这是什么?
> 一个可以屏蔽广告的magisk模块,无需配置,在magisk里安装重启即可使用,使用前需关闭私人dns,不可用wap接入点,AdGuard Home后台管理地址http://127.0.0.1:3000,用户名/密码root
> 一个通过过滤DNS请求来屏蔽广告的magisk模块,也能防止DNS污染,无需配置,在magisk里安装重启即可使用,使用前需关闭私人dns,AdGuard Home后台管理地址http://127.0.0.1:3000,用户名/密码root
# Features
- DNS上游为腾讯阿里的DOH(IP),稳定可靠
- DNS上游为国内4大公共DNS,快速稳定
- 仅内置[秋风广告规则](https://github.com/TG-Twilight/AWAvenue-Ads-Rule),省电,不误杀
-

# 特殊使用环境说明
1. VPN类软件:SSR软件默认设置可用可过滤、V2RayNG软件默认设置可用可过滤,Clash软件默认设置加勾选网络-系统代理(可用但无法过滤),其它软件自行测试。
1. 代理软件:Clash Meta for Android 代理的应用无法过滤(可设置分应用来达到过滤效果),其它软件自行测试。
2. 免流类Magisk模块:免流类模块在全局规则模式都可以使用。
3. 翻墙类Magisk模块:AdGuard Home后台里的DNS上游需全部删除,加一条:127.0.0.1:X (X是翻墙模块的监听端口),才可以使用。
4. 模块默认监听端口为5591,若你有特殊需求,可在AdGuardHome.yaml文件修改 port: 5591 需要重启生效。(注意:若使用53端口,则无法开启热点)
4. 模块默认监听端口为5591,若你有特殊需求,可在AdGuardHome.yaml文件修改 port: 5591 需要重启生效。

# 鸣谢
- [AdguardHome_magisk](https://github.com/410154425/AdGuardHome_magisk)
Expand Down
Binary file renamed AdGuardHome → bin/AdGuardHome
Binary file not shown.
17 changes: 10 additions & 7 deletions AdGuardHome.yaml → bin/AdGuardHome.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,16 @@ dns:
ratelimit_whitelist: []
refuse_any: true
upstream_dns:
- https://223.5.5.5/dns-query
- https://223.6.6.6/dns-query
- https://1.12.12.12/dns-query
- https://120.53.53.53/dns-query
- 114.114.114.114
- 223.5.5.5
- 180.76.76.76
- 119.29.29.29
upstream_dns_file: ""
bootstrap_dns:
- 127.0.0.1
- 9.9.9.10
- 149.112.112.10
- 2620:fe::10
- 2620:fe::fe:10
fallback_dns: []
all_servers: false
fastest_addr: false
Expand Down Expand Up @@ -95,7 +98,7 @@ statistics:
enabled: true
filters:
- enabled: true
url: https://raw.githubusercontent.com/TG-Twilight/AWAvenue-Adblock-Rule/main/AWAvenue-Adblock-Rule.txt
url: https://gcore.jsdelivr.net/gh/TG-Twilight/AWAvenue-Ads-Rule@main/AWAvenue-Ads-Rule.txt
name: 秋风广告规则
id: 1700480708
whitelist_filters: []
Expand Down Expand Up @@ -133,7 +136,7 @@ filtering:
pixabay: true
yandex: true
youtube: true
blocking_mode: default
blocking_mode: null_ip
parental_block_host: family-block.dns.adguard.com
safebrowsing_block_host: standard-block.dns.adguard.com
rewrites: []
Expand Down
65 changes: 63 additions & 2 deletions data/filters/1700480708.txt → bin/data/filters/1700480708.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1,30 @@
[-AWAvenue 秋风广告规则(AWAvenue-Adblock-Rule)-]
[-AWAvenue 秋风广告规则(AWAvenue-Ads-Rule)-]
@@||developers.e.qq.com^
||*-ad-*.byteimg.com^
||*-ad.sm.cn^
||*-ad.wtzw.com^
||*.log.aliyuncs.com^
||1010pic.com^
||8le8le.com^
||a0.app.xiaomi.com^
||acs.m.taobao.com^
||ad-scope.com.cn^
||ad-scope.com^
||ad-sdk.huxiu.com^
||ad.*.xiaomi.com^
||ad.12306.cn^
||ad.51wnl.com^
||ad.bwton.com^
||ad.cyapi.cn^
||ad.partner.gifshow.com^
||ad.qingting.fm^
||ad.qq.com^
||ad.tencentmusic.com^
||ad.toutiao.com^
||ad.winrar.com.cn^
||ad.xelements.cn^
||ad.xiaomi.com^
||ad.ximalaya.com^
||ad.zijieapi.com^
||adapi.izuiyou.com^
||adapi.yynetwk.com^
Expand All @@ -38,19 +47,25 @@
||ads.95516.com^
||ads.google.cn^
||ads.heytapmobi.com^
||ads.huan.tv^
||ads.music.126.net^
||ads.oppomobile.com^
||ads.service.kugou.com^
||ads.service.kugou.com^
||adsense.google.cn^
||adservice.google.cn^
||adservice.google.com^
||adservice.sigmob.cn^
||adserviceretry.kugou.com^
||adsfile.bssdlbig.kugou.com^
||adsfile.bssdlbig.kugou.com^
||adsfilebssdlbig.*.kugou.com^
||adsfilebssdlbig.ali.kugou.com^
||adsfileretry.service.kugou.com^
||adsfs.oppomobile.com^
||adsmind.gdtimg.com^
||adsmind.ugdtimg.com^
||adsp.xunlei.com^
||adstats.tencentmusic.com^
||adtago.s3.amazonaws.com^
||adtech.yahooinc.com^
Expand Down Expand Up @@ -96,6 +111,7 @@
||api.htp.hubcloud.com.cn^
||api.hzsanjiaomao.com^
||api.installer.xiaomi.com^
||api.kingdata.ksyun.com^
||api.statsig.com^
||apiyd.my91app.com^
||app-measurement.com^
Expand All @@ -106,21 +122,27 @@
||azr.footprintdns.com^
||bdapi-ads.realmemobile.com^
||bdapi-in-ads.realmemobile.com^
||bdapi.ads.oppomobile.com^
||beacon-api.aliyuncs.com^
||beacon.qq.com^
||beacons.gvt2.com^
||beizi.biz^
||bingads.microsoft.com^
||books-analytics-events.apple.com^
||bugly.qq.com^
||business-api.tiktok.com
||c.evidon.com^
||c.gj.qq.com^
||c.sayhi.360.cn^
||c2.gdt.qq.com^
||catalog.fjwhcbsh.com^
||catalog.gamepass.com^
||cdn-ads.oss-cn-shanghai.aliyuncs.com^
||cdn.ad.xiaomi.com^
||cdn.ynuf.aliapp.org^
||cfg.imtt.qq.com^
||chat1.jd.com^
||chc.ads.huan.tv^
||ck.ads.oppomobile.com^
||clog.miguvideo.com^
||cm.bilibili.com^
Expand All @@ -137,20 +159,26 @@
||data.mistat.xiaomi.com^
||dataflow.biliapi.com^
||dc.sigmob.cn^
||diagnosis.ad.xiaomi.com^
||dlogs.bwton.com^
||dm.toutiao.com^
||doubleclick-cn.net^
||doubleclick.net^
||download.changhong.upgrade2.huan.tv^
||downloadxml.changhong.upgrade2.huan.tv^
||dsp.fcbox.com^
||dualstack-logs.amap.com^
||dutils.com^
||dxp.baidu.com^
||e.ad.xiaomi.com^
||eclick.baidu.com^
||ef-dongfeng.tanx.com^
||entry.baidu.com^
||errnewlog.umeng.com^
||events-drcn.op.dbankcloud.cn^
||firebaselogging-pa.googleapis.com^
||flurry.com^
||game.loveota.com^
||gdfp.gifshow.com^
||gemini.yahoo.com^
||globalapi.ad.xiaomi.com^
Expand All @@ -170,6 +198,7 @@
||httpdns.bcelive.com^
||httpdns.huaweicloud.com^
||httpdns.ocloud.oppomobile.com^
||httpdns.push.oppomobile.com^
||hugelog.fcbox.com^
||hw-ot-ad.a.yximgs.com^
||hya.comp.360os.com^
Expand All @@ -180,6 +209,7 @@
||iadctest.qwapi.com^
||iadsdk.apple.com^
||iadworkbench.apple.com^
||ifs.tanx.com^
||image-ad.sm.cn^
||imageplus.baidu.com^
||images.pinduoduo.com^
Expand All @@ -192,6 +222,7 @@
||ixav-cse.avlyun.com^
||iyfbodn.com^
||janapi.jd.com^
||jfapi.chiq-cloud.com^
||jiguang.cn^
||jpush.cn^
||jpush.html5.qq.com^
Expand All @@ -200,21 +231,27 @@
||ks.pull.yximgs.com^
||lf1-cdn-tos.bytegoofy.com^
||lf3-ad-union-sdk.pglstatp-toutiao.com^
||liveats-vod.video.ptqy.gitv.tv^
||lm10111.jtrincc.cn^
||log-api-mn.huxiu.com^
||log-api.huxiu.com^
||log-api.pangolin-sdk-toutiao-b.com^
||log-sdk.gifshow.com^
||log-upload-os.hoyoverse.com^
||log-upload.mihoyo.com^
||log.ad.xiaomi.com^
||log.aispeech.com^
||log.avlyun.com^
||log.avlyun.sec.intl.miui.com^
||log.byteoversea.com^
||log.fc.yahoo.com^
||log.kuwo.cn^
||log.stat.kugou.com^
||log.stat.kugou.com^
||log.tagtic.cn^
||log.tbs.qq.com^
||log.vcgame.cn^
||log.web.kugou.com^
||log.web.kugou.com^
||log1.cmpassport.com^
||logbak.hicloud.com^
Expand Down Expand Up @@ -246,6 +283,7 @@
||mobileservice.cn^
||mon.snssdk.com^
||monitor.music.qq.com^
||monitor.uu.qq.com^
||mtj.baidu.com^
||nmetrics.samsung.com^
||notes-analytics-events.apple.com^
Expand Down Expand Up @@ -282,7 +320,9 @@
||pgdt.ugdtimg.com^
||pglstatp-toutiao.com^
||pig.pupuapi.com^
||policy.video.ptqy.gitv.tv^
||public.gdtimg.com^
||q.i.gdt.qq.com^
||qqdata.ab.qq.com^
||qwapi.apple.com^
||qzs.gdtimg.com^
Expand All @@ -299,31 +339,43 @@
||samsung-com.112.2o7.net^
||samsungads.com^
||scdown.qq.com^
||sdk-cache.video.ptqy.gitv.tv^
||sdk.beizi.biz^
||sdk.e.qq.com^
||sdkconf.avlyun.com^
||sdkconfig.ad.intl.xiaomi.com^
||sdkconfig.ad.xiaomi.com^
||sdkconfig.video.qq.com^
||sdkoptedge.chinanetcenter.com^
||sdktmp.hubcloud.com.cn^
||sdownload.stargame.com^
||sensors-log.dongqiudi.com^
||service.changhong.upgrade2.huan.tv^
||service.vmos.cn/vmospro/api/ad^
||sf16-static.i18n-pglstatp.com^
||skdisplay.jd.com^
||slb-p2p.vcloud.ks-live.com^
||smetrics.samsung.com^
||sms.ads.oppomobile.com^
||sngmta.qq.com^
||stat.y.qq.com^
||static.ads-twitter.com^
||staticsns.cdn.bcebos.com^
||stats.qiumibao.com^
||statsigapi.net^
||success.ctobsnssdk.com^
||t*.a.market.xiaomi.com^
||t-dsp.pinduoduo.com^
||t.l.qq.com^
||t.track.ad.xiaomi.com^
||t1.a.market.xiaomi.com^
||t2.a.market.xiaomi.com^
||t3.a.market.xiaomi.com^
||tangram.e.qq.com^
||tdc.qq.com^
||tdid.m.qq.com^
||tj.b.qq.com^
||test.ad.xiaomi.com^
||test.e.ad.xiaomi.com^||tj.b.qq.com^
||tj.video.qq.com^
||tmead.y.qq.com^
||tmfsdk.m.qq.com^
Expand All @@ -335,8 +387,10 @@
||tracker.gitee.com^
||tracking.miui.com^
||tracking.rus.miui.com^
||tvuser-ch.cedock.com^
||tx-ad.a.yximgs.com^
||tx-kmpaudio.pull.yximgs.com^
||uapi.chiq-cloud.com^
||ucstat.baidu.com^
||ulog-sdk.gifshow.com^
||ulogjs.gifshow.com^
Expand All @@ -357,6 +411,7 @@
||v2.gdt.qq.com^
||v3-ad.video.yximgs.com^
||video-dsp.pddpic.com^
||vlive.qqvideo.tc.qq.com^
||vungle.com^
||w*.*skwai.com^
||w.l.qq.com^
Expand Down Expand Up @@ -389,8 +444,12 @@
||weather-analytics-events.apple.com^
||webstat.qiumibao.com^
||win.gdt.qq.com^
||wn.x.jd.com^
||ws-keyboard.shouji.sogou.com^
||ws.sj.qq.com^
||www**.*skwai.com^
||www**.zskwai.com^
||www42.zskwai.com^
||wxa.wxs.qq.com^
||wxsnsdy.wxs.qq.com^
||wxsnsdythumb.wxs.qq.com^
Expand All @@ -400,3 +459,5 @@
||xlog.jd.com^
||xlviiirdr.com^
||xlviirdr.com^
||youxi.kugou.com^
||zeus.ad.xiaomi.com^
8 changes: 4 additions & 4 deletions module.prop
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
id=AdGuardHome
name=AdGuardHome For Magisk
version=20231209
versionCode=5
author=top大佬(酷安)/twoone3
name=AdGuardHome for Magisk
version=20231218
versionCode=6
author=twoone3
description=通过DNS层面过滤广告、防DNS劫持,后台地址http://127.0.0.1:3000,用户名/密码root
42 changes: 29 additions & 13 deletions service.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,33 @@
until [ $(getprop sys.boot_completed) ]; do
sleep 1
done
MODDIR=${0%/*}
chmod +x "$MODDIR/AdGuardHome"
"$MODDIR/AdGuardHome" > "$MODDIR/AdGuardHome.log" 2>&1 &
MODDIR="${0%/*}"
ADG_DIR="$MODDIR/bin"
chmod +x "$ADG_DIR/AdGuardHome"
chown "root:net_admin" "$ADG_DIR/AdGuardHome"
chown "root:net_admin" "$ADG_DIR/AdGuardHome.yaml"
setuidgid "root:net_admin" "$ADG_DIR/AdGuardHome" >"$ADG_DIR/AdGuardHome.log" 2>&1 &
# 读取配置文件的端口
adhome_port="$(cat "$MODDIR/AdGuardHome.yaml" | egrep '^ port: ' | sed -n 's/ port: //g;s/ //g;$p')"
# 新建规则链
iptables -t nat -N ADHOME
# 将 53 端口所有 upd tcp 流量转发到 adguard home
iptables -t nat -A ADHOME -p udp --dport 53 -j REDIRECT --to-ports ${adhome_port}
iptables -t nat -A ADHOME -p tcp --dport 53 -j REDIRECT --to-ports ${adhome_port}
ip6tables -t nat -A ADHOME -p udp --dport 53 -j REDIRECT --to-ports ${adhome_port}
ip6tables -t nat -A ADHOME -p tcp --dort 53 -j REDIRECT --to-ports ${adhome_port}
# 将 ADHOME 规则添加到 OUTPUT
iptables -t nat -A OUTPUT -j ADHOME
adhome_port="$(cat "$ADG_DIR/AdGuardHome.yaml" | egrep '^ port: ' | sed -n 's/ port: //g;s/ //g;$p')"

apply_rules() {
# 新建规则链
iptables -t nat -N ADGUARD
# 返回所有 AdGuardHome 的请求
iptables -t nat -A ADGUARD -m owner --uid-owner "root" --gid-owner "net_admin" -j RETURN
# 将 53 端口所有 udp 流量转发到 adguard home
iptables -t nat -A ADGUARD -p udp --dport 53 -j REDIRECT --to-ports ${adhome_port}
ip6tables -t nat -A ADGUARD -p udp --dport 53 -j REDIRECT --to-ports ${adhome_port}
# 将 ADGUARD 规则添加到 OUTPUT
iptables -t nat -A OUTPUT -j ADGUARD
}

flush_rules() {
iptables -t mangle -F ADGUARD
iptables -t mangle -X ADGUARD

ip6tables -t mangle -F ADGUARD
ip6tables -t mangle -X ADGUARD
}

apply_rules

0 comments on commit 8c1571d

Please sign in to comment.