Skip to content

Commit

Permalink
see changelog.md
Browse files Browse the repository at this point in the history
  • Loading branch information
twoone-3 committed Oct 7, 2024
1 parent bf4a009 commit cf69c58
Show file tree
Hide file tree
Showing 10 changed files with 111 additions and 55 deletions.
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,26 @@
# 特性
- DNS 服务器选用腾讯和阿里的公共 DNS,你也可以在 AdGuardHome 的 DNS 设置里更改来满足你的需求
- 仅内置[秋风广告规则](https://github.com/TG-Twilight/AWAvenue-Ads-Rule),精准,轻量,少误杀
- 在 Magisk/KernelSU 中可以通过模块开关实时启动/关闭模块
- 在 Magisk/KernelSU 中可以通过模块开关实时启动/关闭模块,当然你也可以在shell中模拟模块开关
```shell
touch /data/adb/modules/AdguardHome/disable
```
- 可修改位于 `/data/adb/agh/scripts/config.sh` 的配置文件来调整配置
- 覆盖安装时会自动给原模块创建备份
- 在更新模块时,用户可自行选择是否保留原来的配置文件,即使你选择不保留,也会自动备份原来的配置文件到 `/data/adb/agh/backup` 目录下

# FAQ
> Q: 为什么模块无法屏蔽某些广告?
> Q: 为什么模块无法屏蔽全部广告?
> A: 模块通过转发 53 端口的 DNS 请求来实现广告屏蔽,因此无法屏蔽通过 HTTPS 传输的广告,以及与正常内容同域名的广告,如 知乎,Youtube 等
> A: 模块通过转发 53 端口的 DNS 请求来实现广告屏蔽,因此无法屏蔽通过 HTTPS 传输的广告,以及与正常内容同域名的广告,如 知乎,Youtube 等,好在大部分广告还是优先使用 53 端口的 DNS 请求。
> Q: 为什么装上模块后访问页面变慢?
> A: 因为模块会将所有 DNS 请求转发到 AdGuardHome,再由 AdGuardHome 转发到上游的公共 DNS,中间多了一层转发,但模块默认开启了乐观缓存,在第二次访问时将大大减少延迟
> Q: 模块可以与其它代理模块/软件一起使用吗?
> Q: 为什么本来可以访问的页面一段时间后出现了无法访问?
> A: 可以,一般的代理app可以直接兼容(这里推荐使用[FlClash](https://github.com/chen08209/FlClash)),且 AdGuardHome 的 DNS 查询会经过 VPN,其它代理模块看情况使用,可关闭自动 iptables 规则当作普通 DNS 使用
> A: 由于公共 DNS 请求较慢,模块默认配置文件里开启了乐观缓存,可能导致一些过时的 IP 在过期后仍然被使用,可在后台清理DNS缓存来缓解,或者关闭乐观缓存
> Q: 为什么不接入 KernelSU 的 WebUI?
> Q: 模块可以与其它代理模块/软件一起使用吗?
> A: 由于 KernelSU 的 WebUI 在无法显示确认弹窗,导致 AdGuardHome 管理端一些功能无法使用,因此暂时不接入
> A: 可以,一般的代理app可以直接兼容,且 AdGuardHome 的 DNS 查询会经过 VPN,其它代理模块看情况使用,可关闭自动 iptables 规则当作普通 DNS 使用


# 鸣谢
Expand Down
26 changes: 12 additions & 14 deletions README_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,27 @@ Follow our channel for the latest news, or join our group for discussion!
# Features
- The DNS server uses Tencent and Alibaba's public DNS, you can also change it in the DNS settings of AdGuardHome to meet your needs.
- Only built-in [Autumn Breeze Ad Rule](https://github.com/TG-Twilight/AWAvenue-Ads-Rule), accurate, lightweight, and low false positives.
- In Magisk/KernelSU, you can start/stop the module in real-time through the module switch.
- In Magisk/KernelSU, you can start/stop the module in real-time using the module switch, or you can simulate the module switch in the shell.
```shell
touch /data/adb/modules/AdguardHome/disable
```
- You can modify the configuration file located in `/data/adb/agh/scripts/config.sh` to adjust the configuration.
- When overwriting installation, the original module will be automatically backed up.
- When updating the module, users can choose whether to keep the original configuration file, even if you choose not to keep it, the original configuration file will be automatically backed up to the `/data/adb/agh/backup` directory.

# FAQ
> Q: Why can't the module block some ads?
> Q: Why can't the module block all ads?
> A: The module blocks ads by forwarding DNS requests on port 53, so it cannot block ads transmitted over HTTPS or ads on the same domain as normal content, such as Zhihu, Youtube, etc.
> A: The module blocks ads by forwarding DNS requests on port 53, so it cannot block ads transmitted over HTTPS or ads on the same domain as normal content, such as Zhihu, Youtube, etc., but fortunately, most ads still prefer to use DNS requests on port 53.
> Q: Why does the page slow down after installing the module?
> A: Because the module forwards all DNS requests to AdGuardHome, which then forwards them to the upstream public DNS, adding an extra layer of forwarding, but the module has optimistic caching enabled by default, which greatly reduces latency on the second visit.
> Q: Why can't I access a page that I could access before after a while?
> Q: Can the module be used with other proxy modules/software?
> A: Because public DNS requests are slow, the module's default configuration file has optimistic caching enabled, which may cause some outdated IPs to continue to be used after they expire, you can clear the DNS cache in the background to alleviate this, or disable optimistic caching.
> A: Yes, general proxy apps can be directly compatible (here we recommend using [FlClash](https://github.com/chen08209/FlClash)), and AdGuardHome's DNS queries will pass through the VPN, other proxy modules can be used as needed, and the automatic iptables rules can be turned off for normal DNS use.
> Q: Can the module be used with other proxy modules/software?
> Q: Why not integrate with KernelSU's WebUI?
> A: Yes, general proxy apps are directly compatible, and AdGuardHome's DNS queries will pass through the VPN, other proxy modules can be used as needed, you can disable automatic iptables rules to use it as a regular DNS.
> A: Because KernelSU's WebUI cannot display confirmation pop-ups, some functions of AdGuardHome's management end cannot be used, so it is not integrated for the time being.
# Acknowledgments
- [AdguardHome_magisk](https://github.com/410154425/AdGuardHome_magisk)
- [akashaProxy](https://github.com/ModuleList/akashaProxy)
- [box_for_magisk](https://github.com/taamarin/box_for_magisk)
- Translated with DeepL.com (free version)
- [box_for_magisk](https://github.com/taamarin/box_for_magisk)
4 changes: 2 additions & 2 deletions agh_service.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

(
while [ "$(getprop init.svc.bootanim)" != "stopped" ]; do
echo "Waiting for system to finish booting..." >/data/adb/agh/agh.log
sleep 5
echo "Waiting for system to finish booting..." >>/data/adb/agh/agh.log
sleep 8
done
AGH_DIR="/data/adb/agh"
SCRIPT_DIR="$AGH_DIR/scripts"
Expand Down
13 changes: 8 additions & 5 deletions bin/AdGuardHome.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,21 @@ dns:
ratelimit_whitelist: []
refuse_any: true
upstream_dns:
- tls://223.5.5.5
- tls://1.12.12.12
- https://223.5.5.5/dns-query
- https://1.12.12.12/dns-query
upstream_dns_file: ""
bootstrap_dns:
- 223.5.5.5
- 119.29.29.29
fallback_dns: []
upstream_mode: load_balance
upstream_mode: parallel
fastest_timeout: 1s
allowed_clients: []
disallowed_clients: []
blocked_hosts: []
blocked_hosts:
- version.bind
- id.server
- hostname.bind
trusted_proxies:
- 127.0.0.0/8
- ::1/128
Expand Down Expand Up @@ -140,7 +143,7 @@ filtering:
parental_cache_size: 1048576
cache_time: 30
filters_update_interval: 168
blocked_response_ttl: 10
blocked_response_ttl: 30
filtering_enabled: true
parental_enabled: false
safebrowsing_enabled: false
Expand Down
10 changes: 7 additions & 3 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# ChangeLog
- 修复关闭模块时开机仍然启动的问题
- fix the problem that the module is still started when the module is closed
- 修复manual选项不生效的问题
- fix manual option not work
- 更改了模块更新安装时的备份方式
- change the backup method when updating the module
- 更新了 README.md
- update README.md
- update README.md
- 更改了默认DNS查询方式为parallel,提高了查询速度
- change the default DNS query method to parallel, improve the query speed
69 changes: 58 additions & 11 deletions customize.sh
Original file line number Diff line number Diff line change
@@ -1,29 +1,75 @@
#!/system/bin/sh
SKIPUNZIP=1

ui_print "- 开始安装 AdGuardHome for $ARCH"
ui_print "- Installing AdGuardHome for $ARCH"

AGH_DIR="/data/adb/agh"
BIN_DIR="$AGH_DIR/bin"
SCRIPT_DIR="$AGH_DIR/scripts"
BACKUP_DIR="$AGH_DIR/backup"
SERVICE_DIR="/data/adb/service.d"

ui_print "- 解压模块基本文件..."
ui_print "- Extracting module basic files..."
unzip -o "$ZIPFILE" "uninstall.sh" -d $MODPATH
unzip -o "$ZIPFILE" "module.prop" -d $MODPATH
unzip -o "$ZIPFILE" "agh_service.sh" -d $SERVICE_DIR

if [ -d "$AGH_DIR" ]; then
ui_print "- Backup existing installation..."
BACKUP_DIR=$(mktemp -d /data/adb/agh.XXXXXXXXXX)
mv "$AGH_DIR"/* "$BACKUP_DIR"
ui_print "- Backup created at $BACKUP_DIR"
# Stop AdGuardHome
local pid_file="/data/adb/agh/bin/agh_pid"
if [ -f "$pid_file" ]; then
ui_print "- 发现正在运行的 AdGuardHome 进程,正在停止..."
ui_print "- Found running AdGuardHome process, stopping..."
kill -9 $(cat "$pid_file")
rm "$pid_file"
sleep 1
fi
ui_print "- 发现旧版模块,是否保留原来的配置文件?"
ui_print "- Found old version, do you want to keep the old configuration?"
ui_print "- (音量上键 = 是, 音量下键 = 否)"
ui_print "- (Volume Up = Yes, Volume Down = No)"
key_click=""
while [ "$key_click" = "" ]; do
key_click="$(getevent -qlc 1 | awk '{ print $3 }' | grep 'KEY_')"
sleep 0.2
done
case "$key_click" in
"KEY_VOLUMEUP")
ui_print "- 保留原来的配置文件..."
ui_print "- Keeping old configuration files..."
unzip -o "$ZIPFILE" "scripts/*" -x "scripts/config.sh" -d $AGH_DIR
unzip -o "$ZIPFILE" "bin/*" -x "bin/AdGuardHome.yaml" -d $AGH_DIR
;;
*)
if [ ! -d "$BACKUP_DIR" ]; then
mkdir -p "$BACKUP_DIR"
else
rm -r "$BACKUP_DIR"
mkdir -p "$BACKUP_DIR"
fi
ui_print "- 正在备份旧配置文件..."
ui_print "- Backing up old configuration files..."
mv "$AGH_DIR/scripts/config.sh" "$BACKUP_DIR"
mv "$AGH_DIR/bin/AdGuardHome.yaml" "$BACKUP_DIR"
ui_print "- 正在解压脚本文件..."
ui_print "- Extracting script files..."
unzip -o "$ZIPFILE" "scripts/*" -d $AGH_DIR
ui_print "- 正在解压二进制文件..."
ui_print "- Extracting binary files..."
unzip -o "$ZIPFILE" "bin/*" -d $AGH_DIR
;;
esac
else
ui_print "- 第一次安装,正在解压文件..."
ui_print "- First time installation, extracting files..."
mkdir -p "$AGH_DIR" "$BIN_DIR" "$SCRIPT_DIR"
unzip -o "$ZIPFILE" "scripts/*" -d $AGH_DIR
unzip -o "$ZIPFILE" "bin/*" -d $AGH_DIR
fi

ui_print "- Extracting files..."
unzip -o "$ZIPFILE" "uninstall.sh" -d $MODPATH
unzip -o "$ZIPFILE" "module.prop" -d $MODPATH
unzip -o "$ZIPFILE" "agh_service.sh" -d $SERVICE_DIR
unzip -o "$ZIPFILE" "scripts/*" -d $AGH_DIR
unzip -o "$ZIPFILE" "bin/*" -d $AGH_DIR

ui_print "- 正在设置权限..."
ui_print "- Setting permissions..."
chmod +x "$BIN_DIR/AdGuardHome"
chmod +x "$SCRIPT_DIR/inotify.sh"
Expand All @@ -33,4 +79,5 @@ chmod +x "$SERVICE_DIR/agh_service.sh"
chmod +x "$MODPATH/uninstall.sh"
chown root:net_raw "$BIN_DIR/AdGuardHome"

ui_print "- 安装完成,请重启设备。"
ui_print "- Installation completed, please reboot."
4 changes: 2 additions & 2 deletions module.prop
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
id=AdGuardHome
name=AdGuardHome for Magisk
version=20241005
versionCode=21
version=20241007
versionCode=22
author=twoone3
description=Filter ads at the DNS level
updateJson=https://raw.githubusercontent.com/twoone-3/AdGuardHomeForMagisk/main/version.json
2 changes: 1 addition & 1 deletion scripts/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ if ! command -v busybox &> /dev/null; then
export PATH="/data/adb/magisk:/data/adb/ksu/bin:/data/adb/ap/bin:$PATH:/system/bin"
fi

# 是否手动模式,默认关闭,开启后不会自动应用iptables规则
# 手动模式,默认关闭,开启后iptables.sh将跳过运行,如果你要在开机状态下修改本项,请先在Magisk/KernelSU关闭模块以确保预期的行为
# true: 开启
# false: 关闭
manual=false
Expand Down
12 changes: 8 additions & 4 deletions scripts/iptables.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ enable_ipv6() {

# sysctl -w net.ipv6.conf.all.accept_ra=2
# sysctl -w net.ipv6.conf.wlan0.accept_ra=2
# sysctl -w net.ipv6.conf.all.disable_ipv6=0
# sysctl -w net.ipv6.conf.default.disable_ipv6=0
sysctl -w net.ipv6.conf.all.disable_ipv6=0
sysctl -w net.ipv6.conf.default.disable_ipv6=0
# sysctl -w net.ipv6.conf.wlan0.disable_ipv6=0
}

Expand All @@ -69,11 +69,15 @@ disable_ipv6() {

# sysctl -w net.ipv6.conf.all.accept_ra=0
# sysctl -w net.ipv6.conf.wlan0.accept_ra=0
# sysctl -w net.ipv6.conf.all.disable_ipv6=1
# sysctl -w net.ipv6.conf.default.disable_ipv6=1
sysctl -w net.ipv6.conf.all.disable_ipv6=1
sysctl -w net.ipv6.conf.default.disable_ipv6=1
# sysctl -w net.ipv6.conf.wlan0.disable_ipv6=1
}

if [ "$manual" = true ]; then
exit 0
fi

case "$1" in
enable)
enable_iptables
Expand Down
4 changes: 2 additions & 2 deletions version.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"versionCode": 21,
"version": "20241005",
"versionCode": 22,
"version": "20241007",
"zipUrl": "https://github.com/twoone-3/AdGuardHomeForMagisk/releases/latest/download/AdGuardHomeForMagisk-arm64.zip",
"changelog": "https://raw.githubusercontent.com/twoone-3/AdGuardHomeForMagisk/main/changelog.md"
}

0 comments on commit cf69c58

Please sign in to comment.