mirror of
https://github.com/kenzok8/small-package.git
synced 2026-02-08 07:37:13 +08:00
update 2023-03-10 23:37:33
This commit is contained in:
@@ -5,15 +5,28 @@
|
||||
|
||||
## 特点
|
||||
|
||||
- 修复了原MentoHUST在shell下由于libiconv库编译或工作不正常导致的反馈信息乱码问题
|
||||
- ~~修复了原MentoHUST在shell下由于libiconv库编译或工作不正常导致的反馈信息乱码问题~~
|
||||
- 去除了libiconv库的依赖,加入了轻量级的strnormalize库,GBK to UTF-8转换良好
|
||||
- 去除configure等冗余文件,仅保留核心src源码文件
|
||||
- ./src/Makefile中使用通配符`*`指代libpcap版本,通用性更强
|
||||
- ~~./src/Makefile中使用通配符`*`指代libpcap版本,通用性更强~~
|
||||
- Makefile使用`-lpcap`实现自动依赖`libpcap`而无需手动指定版本
|
||||
- 无需手动配置环境变量,无需使用automake和configure生成所需Makefile
|
||||
- 重新完全手动编写./和./src/目录下的Makefile,保证编译的有效性
|
||||
- 无`--disable-notify --disable-encodepass`等配置,保证原汁原味
|
||||
- 无手动`#define NO_DYLOAD`补丁,使用动态加载库函数,ipk包更小,并且更容易编译
|
||||
|
||||
## 贡献
|
||||
|
||||
本项目从开发至今已经接近10年。因为开发初衷是自用,所以并未支持最新算法。
|
||||
|
||||
考虑到各大高校算法不一,现准备尽可能提供更多帮助,提高项目的兼容性。欢迎小伙伴们对此项目进行贡献:
|
||||
|
||||
- 提供抓包的dump文件
|
||||
- 提供算法参考代码或思路
|
||||
- 提供测试环境
|
||||
|
||||
欢迎提交Issue(Feature Request)或PR。我会尽力完善这个项目。
|
||||
|
||||
|
||||
## PreOperation
|
||||
|
||||
@@ -26,14 +39,15 @@
|
||||
|
||||
### 需要的工具
|
||||
- VMWare Workstation虚拟机工具([官网下载](https://www.vmware.com/go/getworkstation-win))
|
||||
- 一个Ubuntu Linux镜像(可以使用最新LTS版本,[20.04LTS下载](https://releases.ubuntu.com/20.04.3/ubuntu-20.04.3-desktop-amd64.iso))
|
||||
- 一个Ubuntu Linux镜像(可以使用最新LTS版本,[22.04LTS下载](https://releases.ubuntu.com/22.04.2/ubuntu-22.04.2-desktop-amd64.iso))
|
||||
- OpenWrt SDK(在[官网](https://downloads.openwrt.org/snapshots/targets/)寻找对应你路由器架构的版本,比如斐讯k2p是ramips的mt7621)
|
||||
- SSH工具。这里推荐MobaXterm。当然你也可以用XShell等。
|
||||
- 本项目的源码
|
||||
|
||||
注:OpenWrt SDK在[官网](https://downloads.openwrt.org/snapshots/targets/)找到对应架构后,在最下面`Supplementary Files → openwrt-sdk-<Platform>_gcc-<version>_musl.Linux-x86_64.tar.xz`,比如斐讯k2p是[openwrt-sdk-ramips-mt7621_gcc-11.2.0_musl.Linux-x86_64.tar.xz](https://downloads.openwrt.org/snapshots/targets/ramips/mt7621/openwrt-sdk-ramips-mt7621_gcc-11.2.0_musl.Linux-x86_64.tar.xz)。
|
||||
注:OpenWrt SDK在[官网](https://downloads.openwrt.org/snapshots/targets/)找到对应架构后,在最下面`Supplementary Files → openwrt-sdk-<Platform>_gcc-<version>_musl.Linux-x86_64.tar.xz`,比如斐讯k2p是[openwrt-sdk-ramips-mt7621_gcc-12.2.0_musl.Linux-x86_64.tar.xz](https://downloads.openwrt.org/snapshots/targets/ramips/mt7621/openwrt-sdk-ramips-mt7621_gcc-12.2.0_musl.Linux-x86_64.tar.xz)。
|
||||
|
||||
### 虚拟机的安装(Tips)
|
||||
关于虚拟机,在这里不多赘述,仅提供一些Tips。如果对虚拟机完全不了解,建议不要继续观看本教程,先找百度谷歌充充电。
|
||||
关于虚拟机,在这里不多赘述,仅提供一些Tips。如果对虚拟机完全不了解,建议不要继续观看本教程,先找百度谷歌充充电。(也可以是ChatGPT或New Bing...?
|
||||
|
||||
- 推荐新手使用**Ubuntu**
|
||||
|
||||
@@ -56,34 +70,26 @@
|
||||
|
||||
使用`Ctrl+Alt+T`组合快捷键打开终端,然后在左侧的Dock中,右键单击,将其锁定,方便以后打开。如下图:
|
||||
|
||||
|
||||

|
||||
|
||||
在下文中,终端里执行的命令,如果是`$`开头,说明是以普通用户执行;如果是`#`开头,说明是以root用户(最高权限)执行。在输入终端时**不用输入**`$`或`#`符号。
|
||||
|
||||
我们的虚拟机是全新系统,缺少许多交叉编译所需的必要组件与工具。先执行如下命令将它们一并安装:
|
||||
|
||||
```bash
|
||||
$ sudo apt install -y git curl build-essential libncurses5-dev zlib1g-dev gawk flex quilt libssl-dev xsltproc libxml-parser-perl mercurial bzr ecj cvs unzip
|
||||
$ sudo apt install -y git curl vim build-essential libncurses5-dev zlib1g-dev gawk flex quilt python3-distutils libssl-dev xsltproc libxml-parser-perl mercurial bzr ecj cvs unzip
|
||||
```
|
||||
|
||||
如果你用的是Fedora系统,则执行如下命令:
|
||||
|
||||
```
|
||||
$ sudo dnf install -y gcc gcc-c++ perl-FindBin perl-File-Copy perl-File-Compare perl-Thread-Queue
|
||||
```
|
||||
|
||||
|
||||
|
||||
下面就是来获取trunk版本的SDK了,执行命令:
|
||||
|
||||
```bash
|
||||
$ cd Downloads/
|
||||
$ wget https://downloads.openwrt.org/snapshots/targets/ramips/mt7621/openwrt-sdk-ramips-mt7621_gcc-11.2.0_musl.Linux-x86_64.tar.xz
|
||||
$ wget https://downloads.openwrt.org/snapshots/targets/ramips/mt7621/openwrt-sdk-ramips-mt7621_gcc-12.2.0_musl.Linux-x86_64.tar.xz
|
||||
```
|
||||
|
||||
下载好SDK后,我们先解压:
|
||||
```bash
|
||||
$ tar -Jxf openwrt-sdk-ramips-mt7621_gcc-11.2.0_musl.Linux-x86_64.tar.xz
|
||||
$ tar -Jxf openwrt-sdk-ramips-mt7621_gcc-12.2.0_musl.Linux-x86_64.tar.xz
|
||||
```
|
||||
可以利用Ubuntu的自动填充,就是输入`tar -Jxf op`然后按一下Tab键,就会自动填充为上面的命令。记住这一点,以后会经常用到,熟练使用自动填充会节约不少时间。
|
||||
|
||||
@@ -113,7 +119,7 @@ $ git clone https://github.com/KyleRicardo/MentoHUST-OpenWrt-ipk.git package/men
|
||||
这里说一下我的Makefile。
|
||||
一个工程中的源文件不计其数,其按类型、功能、模块分别放在若干个目录中,Makefile定义了一系列的规则来指定,哪些文件需要先编译,哪些文件需要后编译,哪些文件需要重新编译,甚至于进行更复杂的功能操作,因为 Makefile就像一个Shell脚本一样,其中也可以执行操作系统的命令。
|
||||
|
||||
Makefile的语法规则并不算复杂,但是新手研究起来也很头大,也不能静下心来去花时间学习Makefile的写法。我虽然起初不会写Makefile,但是折腾了这么久之后,对于一个Makefile,已经不算什么了。于是github上包含了我写的Makefile,同学们可以直接编译。下个版本可能会发布自动从网上下载源码并编译的Makefile。
|
||||
Makefile的语法规则并不算复杂,但是新手研究起来也很头大,也不能静下心来去花时间学习Makefile的写法。我虽然起初不会写Makefile,但是折腾了这么久之后,对于一个Makefile,已经不算什么了。于是GitHub上包含了我写的Makefile,同学们可以直接编译。下个版本可能会发布自动从网上下载源码并编译的Makefile。
|
||||
|
||||
原始的mentohust编码转换是使用的libiconv库,这个库问题特别多,效率低,不方便编译,受802.1X Evasi0n项目的启发,我干脆摒弃了libiconv库,使用了strnormalize这个文件代替了它,一次性解决了编码转换问题。所以现在,Makefile里面再也找不到iconv的依赖了,现在mentohust唯一依赖的库就是libpcap,编译起来也是相当轻松了。
|
||||
|
||||
@@ -125,11 +131,11 @@ $ make menuconfig
|
||||
|
||||
在Makefile里面我们已经知道,这个软件包是属于Network里的Ruijie,所以我们在主菜单中找到Network,回车进入,然后找到Ruijie这一项
|
||||
|
||||

|
||||

|
||||
|
||||
然后到这里
|
||||
|
||||

|
||||

|
||||
|
||||
我们会发现系统已经自动帮我们选中了该软件包。如果没有,我们按M键选中,将其编译为一个组件模块(Module)。
|
||||
|
||||
@@ -149,83 +155,28 @@ $ make package/mentohust/compile -j$((`nproc`+1)) V=s
|
||||
$ make package/mentohust/compile V=s
|
||||
```
|
||||
|
||||
如果顺利,编译完成之后就能在`<OpenWrt SDK>/bin/packages/<YourArchitecture>/base`中找到你的ipk包了。还包含其依赖的libpcap.ipk。如果你的路由器默认没有安装libpcap包,可以一并安装。
|
||||
如果顺利,编译完成之后就能在`<OpenWrt SDK>/bin/packages/<YourArchitecture>/base`中找到你的ipk包了。比如我虚拟机中的位置为:
|
||||
|
||||
```
|
||||
~/Downloads/openwrt-sdk-ramips-mt7621_gcc-12.2.0_musl.Linux-x86_64/bin/packages/mipsel_24kc/base
|
||||
```
|
||||
|
||||

|
||||
|
||||
其中还包含其依赖的libpcap.ipk。如果你的路由器默认没有安装libpcap包,可以一并安装。
|
||||
|
||||
## Install
|
||||
|
||||
将上面拷贝出来的mentohust及libpcap的ipk,用上面的方法,利用WinSCP上传到路由器的tmp目录。这个操作很简单,这里不再赘述。
|
||||
将上面拷贝出来的mentohust及libpcap的ipk,通过SCP拷贝到路由器的`/tmp`目录下。
|
||||
|
||||
使用快捷键`Ctrl+P`打开PuTTY,输入密码(默认是admin)回车后,来到如下界面:
|
||||
然后`cd`到`/tmp`目录,执行:
|
||||
|
||||

|
||||
|
||||
然后我们先`cd /tmp/`
|
||||
然后用`opkg`命令安装我们所需的软件包:
|
||||
|
||||
```
|
||||
opkg install libpcap_1.7.4-1_ramips_24kec.ipk
|
||||
opkg install mentohust_0.3.1-1_ramips_24kec.ipk
|
||||
```bash
|
||||
$ opkg install libpcap1_1.10.3-1_mipsel_24kc.ipk
|
||||
$ opkg install mentohust_0.3.1-1_mipsel_24kc.ipk
|
||||
```
|
||||
|
||||
这时有可能会出现这种情况:
|
||||
|
||||

|
||||
|
||||
遇到这种错误,需要修改/etc/opkg.conf文件,对于小米Mini,需要在其尾部追加:
|
||||
|
||||
```
|
||||
arch all 1
|
||||
arch ralink 200
|
||||
arch ramips_24kec 100
|
||||
```
|
||||
|
||||
这样就能正确地安装了:
|
||||
|
||||

|
||||
|
||||
当然,mentohust也可以了:
|
||||
|
||||

|
||||
|
||||
在有些比较老的路由器固件中安装,会有类似这样的错误:
|
||||
|
||||
> //usr/lib/opkg/info/mentohust: line 4: default_postinst: not found
|
||||
> Collected errors:
|
||||
>
|
||||
> pkg_run_script: package "mentohust" postinst script returned status 127.
|
||||
> opkg_configure: dnsmasq-full.postinst returned 127.
|
||||
|
||||
上述错误原因如下:
|
||||
|
||||
因为evasi0n是基于 trunk 代码编译,所以目前编译出的ipk 包默认带有
|
||||
Package/postinst 脚本
|
||||
|
||||
```
|
||||
#!/bin/sh
|
||||
|
||||
[ "${IPKG_NO_SCRIPT}" = "1" ] && exit 0
|
||||
|
||||
. ${IPKG_INSTROOT}/lib/functions.sh
|
||||
|
||||
default_postinst$0 $@
|
||||
```
|
||||
Package/prerm 脚本
|
||||
```
|
||||
#!/bin/sh
|
||||
|
||||
. ${IPKG_INSTROOT}/lib/functions.sh
|
||||
|
||||
default_prerm $0$@
|
||||
```
|
||||
而若不是最新编译的固件, /lib/functions.sh 中是没有 default_postinst default_prerm函数的,所以会造成 127错误。
|
||||
|
||||
临时解决办法:
|
||||
在PuTTY中,键入如下命令并回车:
|
||||
|
||||
`echo -e "\ndefault_postinst() {\n\treturn0\n}\ndefault_prerm() {\n\treturn 0\n}" >> /lib/functions.sh`
|
||||
|
||||
注意,这是一条命令,是用echo命令将这段空函数追加到functions.sh文件尾部。
|
||||
上述错误解决之后,终于可以愉快地安装mentohust了。
|
||||
结束。现在2023年了,很多之前会出现的问题已经不复存在了。
|
||||
|
||||
## Usage
|
||||
|
||||
@@ -238,6 +189,6 @@ default_prerm $0$@
|
||||
## 已知问题
|
||||
|
||||
- mentohust未能智能识别路由器WAN口对应的网卡,请手动在mentohust.conf的末尾DHCP脚本中添加自己WAN口对应的网卡。最终脚本类似`udhcpc -i eth1`
|
||||
- 暂未加入init.d目录的mentohust脚本,可能下个版本加入。
|
||||
- ~~暂未加入init.d目录的mentohust脚本,可能下个版本加入。~~已加入自启动脚本
|
||||
- 后续可能加入只有一个Makefile,通过自动从git下载源码进行编译的版本
|
||||
|
||||
|
||||
@@ -3,7 +3,10 @@ local fs = require "nixio.fs"
|
||||
local http = require "luci.http"
|
||||
local uci = require"luci.model.uci".cursor()
|
||||
function index()
|
||||
entry({"admin", "services", "AdGuardHome"}, alias("admin", "services", "AdGuardHome", "base"), _("AdGuard Home"), 11).dependent = true
|
||||
local page = entry({"admin", "services", "AdGuardHome"},alias("admin", "services", "AdGuardHome", "base"),_("AdGuard Home"))
|
||||
page.order = 11
|
||||
page.dependent = true
|
||||
page.acl_depends = { "luci-app-adguardhome" }
|
||||
entry({"admin", "services", "AdGuardHome", "base"}, cbi("AdGuardHome/base"), _("Base Setting"), 1).leaf = true
|
||||
entry({"admin", "services", "AdGuardHome", "log"}, form("AdGuardHome/log"), _("Log"), 2).leaf = true
|
||||
entry({"admin", "services", "AdGuardHome", "manual"}, cbi("AdGuardHome/manual"), _("Manual Config"), 3).leaf = true
|
||||
@@ -65,10 +68,10 @@ function do_update()
|
||||
else
|
||||
arg=""
|
||||
end
|
||||
if fs.access("/var/run/update_core") then
|
||||
if arg=="force" then
|
||||
if arg=="force" then
|
||||
luci.sys.exec("kill $(pgrep /usr/share/AdGuardHome/update_core.sh) ; sh /usr/share/AdGuardHome/update_core.sh "..arg.." >/tmp/AdGuardHome_update.log 2>&1 &")
|
||||
end
|
||||
|
||||
|
||||
else
|
||||
luci.sys.exec("sh /usr/share/AdGuardHome/update_core.sh "..arg.." >/tmp/AdGuardHome_update.log 2>&1 &")
|
||||
end
|
||||
@@ -89,7 +92,13 @@ function get_log()
|
||||
return
|
||||
end
|
||||
http.prepare_content("text/plain; charset=utf-8")
|
||||
local fdp = tonumber(fs.readfile("/var/run/lucilogpos")) or 0
|
||||
local fdp
|
||||
if fs.access("/var/run/lucilogreload") then
|
||||
fdp=0
|
||||
fs.remove("/var/run/lucilogreload")
|
||||
else
|
||||
fdp=tonumber(fs.readfile("/var/run/lucilogpos")) or 0
|
||||
end
|
||||
local f=io.open(logfile, "r+")
|
||||
f:seek("set",fdp)
|
||||
local a=f:read(2048000) or ""
|
||||
|
||||
@@ -24,11 +24,10 @@ o.placeholder=3000
|
||||
o.default=3000
|
||||
o.datatype="port"
|
||||
o.optional = false
|
||||
o.description = translate("<input type='button' style='width:210px; border-color:Teal; text-align:center; font-weight:bold;color:Green;' value='AdGuardHome Web:" .. httpport .. "' onclick=\"window.open('http://'+window.location.hostname+':" .. httpport .. "')\"/>")
|
||||
|
||||
o.description = translate("<input type='button' style='width:210px; border-color:Teal; text-align:center; font-weight:bold;color:Green;padding: .75rem 1rem;background:#f36c21;' value='AdGuardHome Web:" .. httpport .. "' onclick=\"window.open('http://'+window.location.hostname+':" .. httpport .. "')\"/>")
|
||||
---- update warning not safe
|
||||
local binmtime = uci:get("AdGuardHome", "AdGuardHome", "binmtime") or "0"
|
||||
local e = ""
|
||||
local binmtime=uci:get("AdGuardHome","AdGuardHome","binmtime") or "0"
|
||||
local e=""
|
||||
if not fs.access(configpath) then e = e .. " " .. translate("no config") end
|
||||
if not fs.access(binpath) then
|
||||
e=e.." "..translate("no core")
|
||||
@@ -39,25 +38,18 @@ else
|
||||
-- local tmp=luci.sys.exec(binpath.." -c /dev/null --check-config 2>&1| grep -m 1 -E 'v[0-9.]+' -o")
|
||||
-- version=string.sub(tmp, 1, -2)
|
||||
version = luci.sys.exec(string.format("echo -n $(%s --version 2>&1 | awk -F 'version ' '{print $2}' | awk -F ',' '{print $1}')", binpath))
|
||||
if version=="" then version="core error" end
|
||||
uci:set("AdGuardHome","AdGuardHome","version",version)
|
||||
uci:set("AdGuardHome","AdGuardHome","binmtime",testtime)
|
||||
if version == "" then version = "core error" end
|
||||
uci:set("AdGuardHome", "AdGuardHome", "version", version)
|
||||
uci:set("AdGuardHome", "AdGuardHome", "binmtime", testtime)
|
||||
uci:commit("AdGuardHome")
|
||||
end
|
||||
e=version..e
|
||||
end
|
||||
|
||||
o = s:option(ListValue, "core_version", translate("Core Version"))
|
||||
o:value("latest", translate("Latest Version"))
|
||||
o:value("beta", translate("Beta Version"))
|
||||
o.default = "latest"
|
||||
|
||||
o = s:option(Button, "restart", translate("Upgrade Core"))
|
||||
o.inputtitle = translate("Update core version")
|
||||
o=s:option(Button,"restart",translate("Update"))
|
||||
o.inputtitle=translate("Update core version")
|
||||
o.template = "AdGuardHome/AdGuardHome_check"
|
||||
o.showfastconfig = (not fs.access(configpath))
|
||||
o.description = string.format(translate("Current core version:") .. "<strong><font id='updateversion' color='green'>%s </font></strong>", e)
|
||||
|
||||
o.showfastconfig=(not fs.access(configpath))
|
||||
o.description=string.format(translate("core version:").."<strong><font id=\"updateversion\" color=\"green\">%s </font></strong>",e)
|
||||
---- port warning not safe
|
||||
local port=luci.sys.exec("awk '/ port:/{printf($2);exit;}' "..configpath.." 2>nul")
|
||||
if (port=="") then port="?" end
|
||||
@@ -271,12 +263,18 @@ o.widget = "checkbox"
|
||||
o.default = nil
|
||||
o.optional=true
|
||||
|
||||
o = s:option(Value, "update_url", translate("Core Update URL"))
|
||||
o.default = "https://github.com/AdguardTeam/AdGuardHome/releases/download/${Cloud_Version}/AdGuardHome_linux_${Arch}.tar.gz"
|
||||
o.placeholder = "https://github.com/AdguardTeam/AdGuardHome/releases/download/${Cloud_Version}/AdGuardHome_linux_${Arch}.tar.gz"
|
||||
o.rmempty = false
|
||||
----downloadpath
|
||||
o = s:option(TextValue, "downloadlinks",translate("Download links for update"))
|
||||
o.optional = false
|
||||
|
||||
o.rows = 4
|
||||
o.wrap = "soft"
|
||||
o.cfgvalue = function(self, section)
|
||||
return fs.readfile("/usr/share/AdGuardHome/links.txt")
|
||||
end
|
||||
o.write = function(self, section, value)
|
||||
fs.writefile("/usr/share/AdGuardHome/links.txt", value:gsub("\r\n", "\n"))
|
||||
end
|
||||
fs.writefile("/var/run/lucilogpos","0")
|
||||
function m.on_commit(map)
|
||||
if (fs.access("/var/run/AdGserverdis")) then
|
||||
io.popen("/etc/init.d/AdGuardHome reload &")
|
||||
@@ -299,7 +297,7 @@ function m.on_commit(map)
|
||||
uci:set("AdGuardHome","AdGuardHome","ucitracktest","2")
|
||||
end
|
||||
end
|
||||
uci:commit("AdGuardHome")
|
||||
uci:save("AdGuardHome")
|
||||
end
|
||||
end
|
||||
return m
|
||||
|
||||
@@ -12,5 +12,5 @@ t.readonly="readonly"
|
||||
local logfile=uci:get("AdGuardHome","AdGuardHome","logfile") or ""
|
||||
t.timereplace=(logfile~="syslog" and logfile~="" )
|
||||
t.pollcheck=logfile~=""
|
||||
fs.writefile("/var/run/lucilogpos", "0")
|
||||
fs.writefile("/var/run/lucilogreload","")
|
||||
return f
|
||||
|
||||
@@ -6,32 +6,30 @@ require("string")
|
||||
require("io")
|
||||
require("table")
|
||||
function gen_template_config()
|
||||
local b
|
||||
local d = ""
|
||||
local file = "/tmp/resolv.conf.d/resolv.conf.auto"
|
||||
if not fs.access(file) then
|
||||
file = "/tmp/resolv.conf.auto"
|
||||
local b
|
||||
local d=""
|
||||
for cnt in io.lines("/tmp/resolv.conf.d/resolv.conf.auto") do
|
||||
b=string.match (cnt,"^[^#]*nameserver%s+([^%s]+)$")
|
||||
if (b~=nil) then
|
||||
d=d.." - "..b.."\n"
|
||||
end
|
||||
end
|
||||
for cnt in io.lines(file) do
|
||||
b = string.match(cnt, "^[^#]*nameserver%s+([^%s]+)$")
|
||||
if (b ~= nil) then d = d .. " - " .. b .. "\n" end
|
||||
end
|
||||
local f = io.open("/usr/share/AdGuardHome/AdGuardHome_template.yaml", "r+")
|
||||
local tbl = {}
|
||||
local a = ""
|
||||
while (1) do
|
||||
a = f:read("*l")
|
||||
if (a == "#bootstrap_dns") then
|
||||
a = d
|
||||
elseif (a == "#upstream_dns") then
|
||||
a = d
|
||||
elseif (a == nil) then
|
||||
break
|
||||
end
|
||||
table.insert(tbl, a)
|
||||
end
|
||||
f:close()
|
||||
return table.concat(tbl, "\n")
|
||||
local f=io.open("/usr/share/AdGuardHome/AdGuardHome_template.yaml", "r+")
|
||||
local tbl = {}
|
||||
local a=""
|
||||
while (1) do
|
||||
a=f:read("*l")
|
||||
if (a=="#bootstrap_dns") then
|
||||
a=d
|
||||
elseif (a=="#upstream_dns") then
|
||||
a=d
|
||||
elseif (a==nil) then
|
||||
break
|
||||
end
|
||||
table.insert(tbl, a)
|
||||
end
|
||||
f:close()
|
||||
return table.concat(tbl, "\n")
|
||||
end
|
||||
m = Map("AdGuardHome")
|
||||
local configpath = uci:get("AdGuardHome","AdGuardHome","configpath")
|
||||
|
||||
@@ -4,15 +4,15 @@ XHR.poll(3, '<%=url([[admin]], [[services]], [[AdGuardHome]], [[status]])%>', nu
|
||||
var tb = document.getElementById('AdGuardHome_status');
|
||||
if (data && tb) {
|
||||
if (data.running) {
|
||||
tb.innerHTML = '<em><b><font color=green>AdGuardHome <%:RUNNING%></font></b></em>';
|
||||
tb.innerHTML = '<em><b style=color:green>AdGuardHome <%:RUNNING%></b></em>';
|
||||
} else {
|
||||
tb.innerHTML = '<em><b><font color=red>AdGuardHome <%:NOT RUNNING%></font></b></em>';
|
||||
tb.innerHTML = '<em><b style=color:red>AdGuardHome <%:NOT RUNNING%></b></em>';
|
||||
}
|
||||
if (data.redirect)
|
||||
{
|
||||
tb.innerHTML+='<em><b><font color=green><%:Redirected%></font></b></em>'
|
||||
tb.innerHTML+='<em><b style=color:green><%:Redirected%></b></em>'
|
||||
} else {
|
||||
tb.innerHTML+='<em><b><font color=red><%:Not redirect%></font></b></em>'
|
||||
tb.innerHTML+='<em><b style=color:red><%:Not redirect%></b></em>'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,12 +83,13 @@ XHR.poll(3, '<%=url([[admin]], [[services]], [[AdGuardHome]], [[getlog]])%>', nu
|
||||
if (x.responseText && lv) {
|
||||
if (isutc2local)
|
||||
{
|
||||
var lines=line_tolocal(x.responseText);
|
||||
var lines=line_toUTC(x.responseText);
|
||||
if (islogreverse){
|
||||
lv.innerHTML = lines.reverse().join('\n')+lv.innerHTML;
|
||||
}else{
|
||||
lv.innerHTML += lines.join('\n');
|
||||
}
|
||||
lv.innerHTML=line_tolocal(lv.innerHTML).join('\n');
|
||||
}else{
|
||||
if (islogreverse){
|
||||
lv.innerHTML = x.responseText.split('\n').reverse().join('\n')+lv.innerHTML;
|
||||
|
||||
@@ -8,8 +8,8 @@ msgstr "日志"
|
||||
msgid "AdGuardHome's version"
|
||||
msgstr "AdGuardHome 版本"
|
||||
|
||||
msgid 'Needed to click "save apply" to generate the configuration file'
|
||||
msgstr '需要点击“保存并应用”才能生成配置文件'
|
||||
msgid "Needed to click 'save&apply' to generate the configuration file"
|
||||
msgstr "需要点击“保存并应用”才能生成配置文件"
|
||||
|
||||
msgid "In case of the latest realease is a source code that can not download the binary file"
|
||||
msgstr "防止最新release只有源码,导致下载不成功"
|
||||
@@ -41,9 +41,10 @@ msgstr "启用"
|
||||
msgid "Browser management port"
|
||||
msgstr "网页管理账号和密码:admin ,端口:"
|
||||
|
||||
msgid "Upgrade Core"
|
||||
msgstr "更新核心"
|
||||
msgid "Update"
|
||||
msgstr "更新"
|
||||
|
||||
#button change
|
||||
msgid "Update core version"
|
||||
msgstr "更新核心版本"
|
||||
|
||||
@@ -55,22 +56,15 @@ msgstr "已更新"
|
||||
|
||||
#button hide
|
||||
msgid "Force update"
|
||||
msgstr "强制更新核心"
|
||||
msgstr "强制更新"
|
||||
|
||||
msgid "Fast config"
|
||||
msgstr "快速配置"
|
||||
|
||||
msgid "Core Version"
|
||||
msgstr "核心版本"
|
||||
|
||||
msgid "Latest Version"
|
||||
msgstr "最新版"
|
||||
|
||||
msgid "Beta Version"
|
||||
msgstr "测试版"
|
||||
|
||||
msgid "Current core version:"
|
||||
msgstr "当前核心版本:"
|
||||
#
|
||||
msgid "core version:"
|
||||
msgstr "核心版本:"
|
||||
#description change
|
||||
|
||||
msgid "no config"
|
||||
msgstr "没有配置文件"
|
||||
@@ -125,8 +119,8 @@ msgid "try even more compression variants [very slow]"
|
||||
msgstr "尝试更多变体压缩手段[很慢]"
|
||||
|
||||
msgid "bin use less space,but may have compatibility issues"
|
||||
msgstr "减小执行文件空间占用, 压缩后存在兼容性问题"
|
||||
|
||||
msgstr "减小执行文件空间占用,但是可能压缩后有兼容性问题"
|
||||
#
|
||||
msgid "Config Path"
|
||||
msgstr "配置文件路径"
|
||||
|
||||
@@ -196,7 +190,7 @@ msgid "is empty"
|
||||
msgstr "为空"
|
||||
|
||||
msgid "Press load culculate model and culculate finally save/apply"
|
||||
msgstr "先输入你想要的密码, 点击[载入计算模块], 然后点击[计算], 最后点击下方[保存&应用]"
|
||||
msgstr "按载入计算模块 然后计算 最后保存/提交"
|
||||
|
||||
#
|
||||
msgid "Keep files when system upgrade"
|
||||
@@ -217,13 +211,13 @@ msgstr "审计日志.json"
|
||||
|
||||
#
|
||||
msgid "On boot when network ok restart"
|
||||
msgstr "开机后网络就绪时重启"
|
||||
msgstr "开机后网络准备好时重启"
|
||||
|
||||
msgid "Backup workdir files when shutdown"
|
||||
msgstr "在关机时备份以下文件"
|
||||
msgstr "在关机时备份工作目录文件"
|
||||
|
||||
msgid "Will be restore when workdir/data is empty"
|
||||
msgstr "备份将在 工作目录/data 为空的时候恢复"
|
||||
msgstr "在工作目录/data为空的时候恢复"
|
||||
|
||||
msgid "Backup workdir path"
|
||||
msgstr "工作目录备份路径"
|
||||
@@ -241,16 +235,16 @@ msgid "Auto tail runtime log"
|
||||
msgstr "自动截短运行日志"
|
||||
|
||||
msgid "Auto update ipv6 hosts and restart adh"
|
||||
msgstr "自动更新 IPv6 主机并重启 AdGuardHome"
|
||||
msgstr "自动更新ipv6主机并重启adh"
|
||||
|
||||
msgid "Auto update gfwlist and restart adh"
|
||||
msgstr "自动更新 GFW 列表并重启 AdGuardHome"
|
||||
msgstr "自动更新gfw列表并重启adh"
|
||||
|
||||
msgid "Please change time and args in crontab"
|
||||
msgstr "请在计划任务中修改时间和参数"
|
||||
|
||||
msgid "Core Update URL"
|
||||
msgstr "核心更新地址"
|
||||
msgid "Download links for update"
|
||||
msgstr "升级用的下载链接"
|
||||
|
||||
#/cgi-bin/luci/admin/services/AdGuardHome/log/
|
||||
msgid "reverse"
|
||||
@@ -260,7 +254,7 @@ msgid "localtime"
|
||||
msgstr "本地时间"
|
||||
|
||||
msgid "Please add log path in config to enable log"
|
||||
msgstr "请在设置里填写运行日志路径以启用日志"
|
||||
msgstr "请在设置里填写日志路径以启用日志"
|
||||
|
||||
msgid "dellog"
|
||||
msgstr "删除日志"
|
||||
@@ -272,14 +266,16 @@ msgstr "下载日志"
|
||||
msgid "Use template"
|
||||
msgstr "使用模板"
|
||||
|
||||
#hide button
|
||||
msgid "Reload Config"
|
||||
msgstr "重新载入配置"
|
||||
|
||||
msgid "WARNING!!! no bin found apply config will not be test"
|
||||
msgstr "警告!!! 未找到执行文件, 提交配置将不会进行校验"
|
||||
msgstr "警告!!!未找到执行文件,提交配置将不会进行校验"
|
||||
|
||||
#unused
|
||||
msgid "Change browser management username"
|
||||
msgstr "更改网页登录用户名"
|
||||
msgstr "改变网页登录用户名"
|
||||
|
||||
msgid "Username"
|
||||
msgstr "用户名"
|
||||
@@ -294,4 +290,4 @@ msgid "Keep database when system upgrade"
|
||||
msgstr "系统升级时保留数据"
|
||||
|
||||
msgid "Boot delay until network ok"
|
||||
msgstr "开机时等到网络就绪后再启动"
|
||||
msgstr "开机时直到网络准备好再启动"
|
||||
@@ -8,8 +8,8 @@ msgstr "日志"
|
||||
msgid "AdGuardHome's version"
|
||||
msgstr "AdGuardHome 版本"
|
||||
|
||||
msgid 'Needed to click "save apply" to generate the configuration file'
|
||||
msgstr '需要点击“保存并应用”才能生成配置文件'
|
||||
msgid "Needed to click 'save&apply' to generate the configuration file"
|
||||
msgstr "需要点击“保存并应用”才能生成配置文件"
|
||||
|
||||
msgid "In case of the latest realease is a source code that can not download the binary file"
|
||||
msgstr "防止最新release只有源码,导致下载不成功"
|
||||
@@ -41,9 +41,10 @@ msgstr "启用"
|
||||
msgid "Browser management port"
|
||||
msgstr "网页管理账号和密码:admin ,端口:"
|
||||
|
||||
msgid "Upgrade Core"
|
||||
msgstr "更新核心"
|
||||
msgid "Update"
|
||||
msgstr "更新"
|
||||
|
||||
#button change
|
||||
msgid "Update core version"
|
||||
msgstr "更新核心版本"
|
||||
|
||||
@@ -55,22 +56,15 @@ msgstr "已更新"
|
||||
|
||||
#button hide
|
||||
msgid "Force update"
|
||||
msgstr "强制更新核心"
|
||||
msgstr "强制更新"
|
||||
|
||||
msgid "Fast config"
|
||||
msgstr "快速配置"
|
||||
|
||||
msgid "Core Version"
|
||||
msgstr "核心版本"
|
||||
|
||||
msgid "Latest Version"
|
||||
msgstr "最新版"
|
||||
|
||||
msgid "Beta Version"
|
||||
msgstr "测试版"
|
||||
|
||||
msgid "Current core version:"
|
||||
msgstr "当前核心版本:"
|
||||
#
|
||||
msgid "core version:"
|
||||
msgstr "核心版本:"
|
||||
#description change
|
||||
|
||||
msgid "no config"
|
||||
msgstr "没有配置文件"
|
||||
@@ -125,8 +119,8 @@ msgid "try even more compression variants [very slow]"
|
||||
msgstr "尝试更多变体压缩手段[很慢]"
|
||||
|
||||
msgid "bin use less space,but may have compatibility issues"
|
||||
msgstr "减小执行文件空间占用, 压缩后存在兼容性问题"
|
||||
|
||||
msgstr "减小执行文件空间占用,但是可能压缩后有兼容性问题"
|
||||
#
|
||||
msgid "Config Path"
|
||||
msgstr "配置文件路径"
|
||||
|
||||
@@ -196,7 +190,7 @@ msgid "is empty"
|
||||
msgstr "为空"
|
||||
|
||||
msgid "Press load culculate model and culculate finally save/apply"
|
||||
msgstr "先输入你想要的密码, 点击[载入计算模块], 然后点击[计算], 最后点击下方[保存&应用]"
|
||||
msgstr "按载入计算模块 然后计算 最后保存/提交"
|
||||
|
||||
#
|
||||
msgid "Keep files when system upgrade"
|
||||
@@ -217,13 +211,13 @@ msgstr "审计日志.json"
|
||||
|
||||
#
|
||||
msgid "On boot when network ok restart"
|
||||
msgstr "开机后网络就绪时重启"
|
||||
msgstr "开机后网络准备好时重启"
|
||||
|
||||
msgid "Backup workdir files when shutdown"
|
||||
msgstr "在关机时备份以下文件"
|
||||
msgstr "在关机时备份工作目录文件"
|
||||
|
||||
msgid "Will be restore when workdir/data is empty"
|
||||
msgstr "备份将在 工作目录/data 为空的时候恢复"
|
||||
msgstr "在工作目录/data为空的时候恢复"
|
||||
|
||||
msgid "Backup workdir path"
|
||||
msgstr "工作目录备份路径"
|
||||
@@ -241,16 +235,16 @@ msgid "Auto tail runtime log"
|
||||
msgstr "自动截短运行日志"
|
||||
|
||||
msgid "Auto update ipv6 hosts and restart adh"
|
||||
msgstr "自动更新 IPv6 主机并重启 AdGuardHome"
|
||||
msgstr "自动更新ipv6主机并重启adh"
|
||||
|
||||
msgid "Auto update gfwlist and restart adh"
|
||||
msgstr "自动更新 GFW 列表并重启 AdGuardHome"
|
||||
msgstr "自动更新gfw列表并重启adh"
|
||||
|
||||
msgid "Please change time and args in crontab"
|
||||
msgstr "请在计划任务中修改时间和参数"
|
||||
|
||||
msgid "Core Update URL"
|
||||
msgstr "核心更新地址"
|
||||
msgid "Download links for update"
|
||||
msgstr "升级用的下载链接"
|
||||
|
||||
#/cgi-bin/luci/admin/services/AdGuardHome/log/
|
||||
msgid "reverse"
|
||||
@@ -260,7 +254,7 @@ msgid "localtime"
|
||||
msgstr "本地时间"
|
||||
|
||||
msgid "Please add log path in config to enable log"
|
||||
msgstr "请在设置里填写运行日志路径以启用日志"
|
||||
msgstr "请在设置里填写日志路径以启用日志"
|
||||
|
||||
msgid "dellog"
|
||||
msgstr "删除日志"
|
||||
@@ -272,14 +266,16 @@ msgstr "下载日志"
|
||||
msgid "Use template"
|
||||
msgstr "使用模板"
|
||||
|
||||
#hide button
|
||||
msgid "Reload Config"
|
||||
msgstr "重新载入配置"
|
||||
|
||||
msgid "WARNING!!! no bin found apply config will not be test"
|
||||
msgstr "警告!!! 未找到执行文件, 提交配置将不会进行校验"
|
||||
msgstr "警告!!!未找到执行文件,提交配置将不会进行校验"
|
||||
|
||||
#unused
|
||||
msgid "Change browser management username"
|
||||
msgstr "更改网页登录用户名"
|
||||
msgstr "改变网页登录用户名"
|
||||
|
||||
msgid "Username"
|
||||
msgstr "用户名"
|
||||
@@ -294,4 +290,4 @@ msgid "Keep database when system upgrade"
|
||||
msgstr "系统升级时保留数据"
|
||||
|
||||
msgid "Boot delay until network ok"
|
||||
msgstr "开机时等到网络就绪后再启动"
|
||||
msgstr "开机时直到网络准备好再启动"
|
||||
@@ -8,23 +8,24 @@ auth_attempts: 5
|
||||
block_auth_min: 15
|
||||
http_proxy: ""
|
||||
language: zh-cn
|
||||
rlimit_nofile: 0
|
||||
debug_pprof: false
|
||||
web_session_ttl: 720
|
||||
dns:
|
||||
bind_hosts:
|
||||
- 0.0.0.0
|
||||
port: 5553
|
||||
statistics_interval: 30
|
||||
statistics_interval: 1
|
||||
querylog_enabled: true
|
||||
querylog_file_enabled: true
|
||||
querylog_interval: 6h
|
||||
querylog_interval: 1
|
||||
querylog_size_memory: 1000
|
||||
anonymize_client_ip: false
|
||||
protection_enabled: true
|
||||
blocking_mode: default
|
||||
blocking_ipv4: ""
|
||||
blocking_ipv6: ""
|
||||
blocked_response_ttl: 60
|
||||
blocked_response_ttl: 10
|
||||
parental_block_host: family-block.dns.adguard.com
|
||||
safebrowsing_block_host: standard-block.dns.adguard.com
|
||||
ratelimit: 0
|
||||
@@ -211,7 +212,29 @@ filters:
|
||||
name: Adaway HOST
|
||||
id: 139789187
|
||||
whitelist_filters: []
|
||||
user_rules: []
|
||||
user_rules:
|
||||
- '@@||taobao.com^$important'
|
||||
- '@@||tmall.com^$important'
|
||||
- '@@||jd.com^important'
|
||||
- '@@||flyme.cn^$important'
|
||||
- '@@||meizu.com^$important'
|
||||
- '@@||wl.jd.com^$important'
|
||||
- '@@||flydigi.com^'
|
||||
- '@@||pv.sohu.com^$important'
|
||||
- /googleads.$~script,domain=~googleads.github.io
|
||||
- /pagead/lvz?
|
||||
- '||google.com/pagead/'
|
||||
- '||static.doubleclick.net^$domain=youtube.com'
|
||||
- '||youtube.com/get_midroll_'
|
||||
- '||5hz.org^'
|
||||
- '@@||000714.xyz^'
|
||||
- '@@||blueskyxn.com^'
|
||||
- '||topnewsfeeds.net^'
|
||||
- '||nbryb.com^'
|
||||
- '||superbdolly.com^'
|
||||
- '||salutationcheerlessdemote.com^'
|
||||
- '||buildingdoodlesquare.com^'
|
||||
- '||colonistnobilityheroic.com^'
|
||||
dhcp:
|
||||
enabled: false
|
||||
interface_name: ""
|
||||
@@ -236,8 +259,4 @@ log_max_size: 100
|
||||
log_max_age: 3
|
||||
log_file: ""
|
||||
verbose: false
|
||||
os:
|
||||
group: ""
|
||||
user: ""
|
||||
rlimit_nofile: 0
|
||||
schema_version: 12
|
||||
schema_version: 10
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
config AdGuardHome 'AdGuardHome'
|
||||
option enabled '0'
|
||||
option httpport '3000'
|
||||
option redirect 'dnsmasq-upstream'
|
||||
option redirect 'none'
|
||||
option configpath '/etc/AdGuardHome.yaml'
|
||||
option workdir '/etc/AdGuardHome'
|
||||
option logfile '/tmp/AdGuardHome.log'
|
||||
option verbose '0'
|
||||
option binpath '/usr/bin/AdGuardHome'
|
||||
option upxflag ''
|
||||
option upxflag '-1'
|
||||
|
||||
|
||||
@@ -7,12 +7,12 @@ STOP=01
|
||||
|
||||
CONFIGURATION=AdGuardHome
|
||||
CRON_FILE=/etc/crontabs/root
|
||||
|
||||
extra_command "do_redirect" "0 or 1"
|
||||
extra_command "testbackup" "backup or restore"
|
||||
extra_command "test_crontab"
|
||||
extra_command "force_reload"
|
||||
extra_command "isrunning"
|
||||
EXTRA_COMMANDS="do_redirect testbackup test_crontab force_reload isrunning"
|
||||
EXTRA_HELP=" do_redirect 0 or 1\
|
||||
testbackup backup or restore\
|
||||
test_crontab
|
||||
force_reload
|
||||
isrunning"
|
||||
|
||||
set_forward_dnsmasq()
|
||||
{
|
||||
@@ -29,7 +29,7 @@ set_forward_dnsmasq()
|
||||
if [ "$server" = "$addr" ]; then
|
||||
continue
|
||||
fi
|
||||
uci add_list dhcp.@dnsmasq[0].server=$server
|
||||
# uci add_list dhcp.@dnsmasq[0].server=$server
|
||||
done
|
||||
uci delete dhcp.@dnsmasq[0].resolvfile 2>/dev/null
|
||||
uci set dhcp.@dnsmasq[0].noresolv=1
|
||||
@@ -50,9 +50,7 @@ stop_forward_dnsmasq()
|
||||
uci del_list dhcp.@dnsmasq[0].server=$addr 2>/dev/null
|
||||
addrlist="`uci get dhcp.@dnsmasq[0].server 2>/dev/null`"
|
||||
if [ -z "$addrlist" ] ; then
|
||||
resolvfile="/tmp/resolv.conf.d/resolv.conf.auto"
|
||||
[ ! -f "$resolvfile" ] && resolvfile="/tmp/resolv.conf.auto"
|
||||
uci set dhcp.@dnsmasq[0].resolvfile="$resolvfile" 2>/dev/null
|
||||
uci set dhcp.@dnsmasq[0].resolvfile=/tmp/resolv.conf.d/resolv.conf.auto 2>/dev/null
|
||||
uci delete dhcp.@dnsmasq[0].noresolv 2>/dev/null
|
||||
fi
|
||||
uci commit dhcp
|
||||
@@ -71,49 +69,55 @@ set_iptable()
|
||||
set firewall.AdGuardHome.reload=1
|
||||
commit firewall
|
||||
EOF
|
||||
|
||||
[ "$tcp_server" == "1" ] && iptables -t nat -I PREROUTING 1 -m comment --comment "AdGuardHome" -p tcp --dport 53 -j REDIRECT --to-ports $AdGuardHome_PORT
|
||||
iptables -t nat -I PREROUTING 1 -m comment --comment "AdGuardHome" -p udp --dport 53 -j REDIRECT --to-ports $AdGuardHome_PORT
|
||||
|
||||
[ "$ipv6_server" == 0 ] && return
|
||||
IPS="`ifconfig | grep "inet addr" | grep -v ":127" | grep "Bcast" | awk '{print $2}' | awk -F : '{print $2}'`"
|
||||
for IP in $IPS
|
||||
do
|
||||
if [ "$tcp_server" == "1" ]; then
|
||||
iptables -t nat -A PREROUTING -p tcp -d $IP --dport 53 -j REDIRECT --to-ports $AdGuardHome_PORT >/dev/null 2>&1
|
||||
fi
|
||||
iptables -t nat -A PREROUTING -p udp -d $IP --dport 53 -j REDIRECT --to-ports $AdGuardHome_PORT >/dev/null 2>&1
|
||||
done
|
||||
|
||||
[ "$tcp_server" == "1" ] && ip6tables -t nat -I PREROUTING 1 -m comment --comment "AdGuardHome" -p tcp --dport 53 -j REDIRECT --to-ports $AdGuardHome_PORT
|
||||
ip6tables -t nat -I PREROUTING 1 -m comment --comment "AdGuardHome" -p udp --dport 53 -j REDIRECT --to-ports $AdGuardHome_PORT
|
||||
if [ "$ipv6_server" == 0 ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
IPS="`ifconfig | grep "inet6 addr" | grep -v " fe80::" | grep -v " ::1" | grep "Global" | awk '{print $3}'`"
|
||||
for IP in $IPS
|
||||
do
|
||||
if [ "$tcp_server" == "1" ]; then
|
||||
ip6tables -t nat -A PREROUTING -p tcp -d $IP --dport 53 -j REDIRECT --to-ports $AdGuardHome_PORT >/dev/null 2>&1
|
||||
fi
|
||||
ip6tables -t nat -A PREROUTING -p udp -d $IP --dport 53 -j REDIRECT --to-ports $AdGuardHome_PORT >/dev/null 2>&1
|
||||
done
|
||||
}
|
||||
|
||||
clear_iptable() {
|
||||
clear_iptable()
|
||||
{
|
||||
uci -q batch <<-EOF >/dev/null 2>&1
|
||||
delete firewall.AdGuardHome
|
||||
commit firewall
|
||||
EOF
|
||||
local OLD_PORT="$1"
|
||||
local ipv6_server=$2
|
||||
IPS="`ifconfig | grep "inet addr" | grep -v ":127" | grep "Bcast" | awk '{print $2}' | awk -F : '{print $2}'`"
|
||||
for IP in $IPS
|
||||
do
|
||||
iptables -t nat -D PREROUTING -p udp -d $IP --dport 53 -j REDIRECT --to-ports $OLD_PORT >/dev/null 2>&1
|
||||
iptables -t nat -D PREROUTING -p tcp -d $IP --dport 53 -j REDIRECT --to-ports $OLD_PORT >/dev/null 2>&1
|
||||
done
|
||||
|
||||
nums=$(iptables -t nat -n -L PREROUTING 2>/dev/null | grep -c "AdGuardHome")
|
||||
if [ -n "$nums" ]; then
|
||||
until [ "$nums" = 0 ]
|
||||
do
|
||||
rules=$(iptables -t nat -n -L PREROUTING --line-num 2>/dev/null | grep "AdGuardHome" | awk '{print $1}')
|
||||
for rule in $rules
|
||||
do
|
||||
iptables -t nat -D PREROUTING $rule 2> /dev/null
|
||||
break
|
||||
done
|
||||
nums=$(expr $nums - 1)
|
||||
done
|
||||
fi
|
||||
|
||||
nums=$(ip6tables -t nat -n -L PREROUTING 2>/dev/null | grep -c "AdGuardHome")
|
||||
if [ -n "$nums" ]; then
|
||||
until [ "$nums" = 0 ]
|
||||
do
|
||||
rules=$(ip6tables -t nat -n -L PREROUTING --line-num 2>/dev/null | grep "AdGuardHome" | awk '{print $1}')
|
||||
for rule in $rules
|
||||
do
|
||||
ip6tables -t nat -D PREROUTING $rule 2> /dev/null
|
||||
break
|
||||
done
|
||||
nums=$(expr $nums - 1)
|
||||
done
|
||||
if [ "$ipv6_server" == 0 ]; then
|
||||
return
|
||||
fi
|
||||
echo "warn ip6tables nat mod is needed"
|
||||
IPS="`ifconfig | grep "inet6 addr" | grep -v " fe80::" | grep -v " ::1" | grep "Global" | awk '{print $3}'`"
|
||||
for IP in $IPS
|
||||
do
|
||||
ip6tables -t nat -D PREROUTING -p udp -d $IP --dport 53 -j REDIRECT --to-ports $OLD_PORT >/dev/null 2>&1
|
||||
ip6tables -t nat -D PREROUTING -p tcp -d $IP --dport 53 -j REDIRECT --to-ports $OLD_PORT >/dev/null 2>&1
|
||||
done
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
@@ -182,6 +186,8 @@ rm_port53()
|
||||
config_editor "dns.port" "$dnsmasq_port" "$configpath"
|
||||
uci set dhcp.@dnsmasq[0].port="53"
|
||||
uci commit dhcp
|
||||
config_get binpath $CONFIGURATION binpath "/usr/bin/AdGuardHome"
|
||||
killall -9 $binpath
|
||||
/etc/init.d/dnsmasq restart
|
||||
}
|
||||
|
||||
@@ -202,7 +208,7 @@ use_port53()
|
||||
config_editor "dns.port" "53" "$configpath"
|
||||
uci set dhcp.@dnsmasq[0].port="$AdGuardHome_PORT"
|
||||
uci commit dhcp
|
||||
/etc/init.d/dnsmasq restart
|
||||
/etc/init.d/dnsmasq reload
|
||||
}
|
||||
|
||||
do_redirect()
|
||||
@@ -236,7 +242,6 @@ _do_redirect()
|
||||
config_get "old_port" "$section" "old_port" "0"
|
||||
config_get "old_enabled" "$section" "old_enabled" "0"
|
||||
uci get dhcp.@dnsmasq[0].port >/dev/null 2>&1 || uci set dhcp.@dnsmasq[0].port="53" >/dev/null 2>&1
|
||||
uci commit dhcp
|
||||
if [ "$old_enabled" = "1" -a "$old_redirect" == "exchange" ]; then
|
||||
AdGuardHome_PORT=$(uci get dhcp.@dnsmasq[0].port 2>/dev/null)
|
||||
fi
|
||||
@@ -244,7 +249,7 @@ _do_redirect()
|
||||
if [ "$old_redirect" != "$redirect" ] || [ "$old_port" != "$AdGuardHome_PORT" ] || [ "$old_enabled" = "1" -a "$enabled" = "0" ]; then
|
||||
if [ "$old_redirect" != "none" ]; then
|
||||
if [ "$old_redirect" == "redirect" -a "$old_port" != "0" ]; then
|
||||
clear_iptable
|
||||
clear_iptable "$old_port" "$ipv6_server"
|
||||
elif [ "$old_redirect" == "dnsmasq-upstream" ]; then
|
||||
stop_forward_dnsmasq "$old_port"
|
||||
elif [ "$old_redirect" == "exchange" ]; then
|
||||
@@ -253,7 +258,7 @@ _do_redirect()
|
||||
fi
|
||||
elif [ "$old_enabled" = "1" -a "$enabled" = "1" ]; then
|
||||
if [ "$old_redirect" == "redirect" -a "$old_port" != "0" ]; then
|
||||
clear_iptable
|
||||
clear_iptable "$old_port" "$ipv6_server"
|
||||
fi
|
||||
fi
|
||||
uci delete AdGuardHome.@AdGuardHome[0].old_redirect 2>/dev/null
|
||||
@@ -406,7 +411,6 @@ start_service() {
|
||||
# update password
|
||||
config_get hashpass $CONFIGURATION hashpass ""
|
||||
config_get configpath $CONFIGURATION configpath "/etc/AdGuardHome.yaml"
|
||||
[ -f $configpath ] && chmod 777 $configpath
|
||||
if [ -n "$hashpass" ]; then
|
||||
config_editor "users.password" "$hashpass" "$configpath"
|
||||
uci set $CONFIGURATION.$CONFIGURATION.hashpass=""
|
||||
@@ -429,7 +433,7 @@ start_service() {
|
||||
fi
|
||||
# for overlay data-stk-oo not suppport
|
||||
local cwdfs=$(get_filesystem $workdir)
|
||||
echo "文件系统: ${cwdfs}"
|
||||
echo "workdir is a $cwdfs filesystem"
|
||||
if [ "$cwdfs" == "jffs2" ]; then
|
||||
echo "fs error ln db to tmp $workdir $cwdfs"
|
||||
logger "AdGuardHome" "warning db redirect to tmp"
|
||||
@@ -467,8 +471,6 @@ start_service() {
|
||||
_do_redirect 0
|
||||
/usr/share/AdGuardHome/update_core.sh 2>&1 >/tmp/AdGuardHome_update.log &
|
||||
exit 0
|
||||
else
|
||||
chmod 777 $binpath
|
||||
fi
|
||||
|
||||
config_get_bool verbose $CONFIGURATION verbose 0
|
||||
@@ -499,14 +501,20 @@ start_service() {
|
||||
echo "no config start watching"
|
||||
fi
|
||||
fi
|
||||
echo "AdGuardHome 服务已启用"
|
||||
echo "AdGuardHome service enabled"
|
||||
echo "luci enable switch=$enabled"
|
||||
(sleep 10 && [ -z "$(pgrep $binpath)" ] && logger "AdGuardHome" "no process in 10s cancel redirect" && _do_redirect 0 )&
|
||||
if [[ "`uci get bypass.@global[0].global_server 2>/dev/null`" && "`uci get bypass.@global[0].adguardhome 2>/dev/null`" == 1 && "$(uci get dhcp.@dnsmasq[0].port)" == "53" ]]; then
|
||||
uci -q set AdGuardHome.AdGuardHome.redirect='exchange'
|
||||
uci commit AdGuardHome
|
||||
do_redirect 1
|
||||
fi
|
||||
}
|
||||
|
||||
reload_service()
|
||||
{
|
||||
rm /var/run/AdGlucitest >/dev/null 2>&1
|
||||
echo "重载 AdGuardHome 服务..."
|
||||
echo "AdGuardHome reloading"
|
||||
start
|
||||
}
|
||||
|
||||
@@ -539,7 +547,7 @@ stop_service()
|
||||
backup
|
||||
fi
|
||||
fi
|
||||
echo "AdGuardHome 服务已停止"
|
||||
echo "AdGuardHome service disabled"
|
||||
touch /var/run/AdGserverdis
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ uci -q batch <<-EOF >/dev/null 2>&1
|
||||
set ucitrack.@AdGuardHome[-1].init=AdGuardHome
|
||||
commit ucitrack
|
||||
delete AdGuardHome.AdGuardHome.ucitracktest
|
||||
/etc/init.d/AdGuardHome restart
|
||||
EOF
|
||||
|
||||
rm -f /tmp/luci-indexcache
|
||||
|
||||
@@ -7,15 +7,13 @@ users:
|
||||
auth_attempts: 5
|
||||
block_auth_min: 15
|
||||
http_proxy: ""
|
||||
language: ""
|
||||
rlimit_nofile: 0
|
||||
language: zh-cn
|
||||
debug_pprof: false
|
||||
web_session_ttl: 720
|
||||
dns:
|
||||
bind_hosts:
|
||||
- 0.0.0.0
|
||||
port: 5553
|
||||
statistics_interval: 90
|
||||
bind_host: 0.0.0.0
|
||||
port: 1745
|
||||
statistics_interval: 30
|
||||
querylog_enabled: true
|
||||
querylog_file_enabled: true
|
||||
querylog_interval: 6h
|
||||
@@ -30,7 +28,7 @@ dns:
|
||||
safebrowsing_block_host: standard-block.dns.adguard.com
|
||||
ratelimit: 0
|
||||
ratelimit_whitelist: []
|
||||
refuse_any: true
|
||||
refuse_any: false
|
||||
upstream_dns:
|
||||
- 223.5.5.5
|
||||
upstream_dns_file: ""
|
||||
@@ -93,24 +91,21 @@ tls:
|
||||
filters:
|
||||
- enabled: true
|
||||
url: https://adguardteam.github.io/AdGuardSDNSFilter/Filters/filter.txt
|
||||
name: AdGuard Home
|
||||
id: 1
|
||||
name: AdGuard DNS filter
|
||||
id: 1628750870
|
||||
- enabled: true
|
||||
url: https://banbendalao.coding.net/p/adgk/d/ADgk/git/raw/master/ADgk.txt
|
||||
name: AD-gk
|
||||
id: 2
|
||||
- enabled: false
|
||||
url: https://anti-ad.net/easylist.txt
|
||||
name: anti-AD
|
||||
id: 4
|
||||
- enabled: true
|
||||
url: https://raw.githubusercontent.com/o0HalfLife0o/list/master/ad.txt
|
||||
name: HalfLife
|
||||
id: 5
|
||||
name: 'CHN: anti-AD'
|
||||
id: 1628750871
|
||||
whitelist_filters: []
|
||||
user_rules:
|
||||
- '@@||iwx.mail.qq.com^$important'
|
||||
- '@@||gm.mmstat.com^$important'
|
||||
- '@@||taobao.com^$important'
|
||||
- '@@||jd.com^important'
|
||||
- '@@||flyme.cn^$important'
|
||||
- '@@||meizu.com^$important'
|
||||
- '@@||wl.jd.com^$important'
|
||||
- '@@||flydigi.com^'
|
||||
- '@@||pv.sohu.com^$important'
|
||||
dhcp:
|
||||
enabled: false
|
||||
interface_name: ""
|
||||
@@ -135,4 +130,4 @@ log_max_size: 100
|
||||
log_max_age: 3
|
||||
log_file: ""
|
||||
verbose: false
|
||||
schema_version: 10
|
||||
schema_version: 7
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
https://static.adguard.com/adguardhome/beta/AdGuardHome_linux_${Arch}.tar.gz
|
||||
https://github.com/AdguardTeam/AdGuardHome/releases/download/${latest_ver}/AdGuardHome_linux_${Arch}.tar.gz
|
||||
https://static.adguard.com/adguardhome/release/AdGuardHome_linux_${Arch}.tar.gz
|
||||
https://static.adguard.com/adguardhome/beta/AdGuardHome_linux_${Arch}.tar.gz
|
||||
|
||||
@@ -1,17 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
#!/bin/sh
|
||||
PATH="/usr/sbin:/usr/bin:/sbin:/bin"
|
||||
binpath=$(uci get AdGuardHome.AdGuardHome.binpath)
|
||||
if [ -z "$binpath" ]; then
|
||||
uci set AdGuardHome.AdGuardHome.binpath="/tmp/AdGuardHome/AdGuardHome"
|
||||
binpath="/tmp/AdGuardHome/AdGuardHome"
|
||||
if [[ -z ${binpath} ]]; then
|
||||
uci set AdGuardHome.AdGuardHome.binpath="/tmp/AdGuardHome/AdGuardHome"
|
||||
binpath="/tmp/AdGuardHome/AdGuardHome"
|
||||
fi
|
||||
mkdir -p ${binpath%/*}
|
||||
[[ ! -d ${binpath%/*} ]] && mkdir -p ${binpath%/*}
|
||||
upxflag=$(uci get AdGuardHome.AdGuardHome.upxflag 2>/dev/null)
|
||||
LOCKU=/var/lock/AdGuardHome-update.lock
|
||||
[ -f $LOCKU ] && EXIT 1
|
||||
touch $LOCKU
|
||||
|
||||
check_if_already_running(){
|
||||
running_tasks="$(ps |grep "AdGuardHome" |grep "update_core" |grep -v "grep" |awk '{print $1}' |wc -l)"
|
||||
[ "${running_tasks}" -gt "2" ] && echo -e "\nA task is already running." && EXIT 2
|
||||
|
||||
running_tasks=$(ps |grep 'AdGuardHome' |grep 'update_core' |grep -v 'grep' |awk '{print $1}' |wc -l)
|
||||
[ "x${running_tasks}" != "x0" ] && echo -e "\nA task is already running." && EXIT 2
|
||||
}
|
||||
|
||||
check_wgetcurl(){
|
||||
@@ -123,48 +126,37 @@ doupdate_core(){
|
||||
mkdir -p "/tmp/AdGuardHomeupdate"
|
||||
rm -rf /tmp/AdGuardHomeupdate/* >/dev/null 2>&1
|
||||
Archt="$(opkg info kernel | grep Architecture | awk -F "[ _]" '{print($2)}')"
|
||||
case $Archt in
|
||||
"i386")
|
||||
Arch="386"
|
||||
;;
|
||||
"i686")
|
||||
Arch="386"
|
||||
;;
|
||||
"x86")
|
||||
Arch="amd64"
|
||||
;;
|
||||
"mipsel")
|
||||
Arch="mipsle"
|
||||
;;
|
||||
"mips64el")
|
||||
Arch="mips64le"
|
||||
Arch="mipsle"
|
||||
echo -e "mips64el use $Arch may have bug"
|
||||
;;
|
||||
"mips")
|
||||
Arch="mips"
|
||||
;;
|
||||
"mips64")
|
||||
Arch="mips64"
|
||||
Arch="mips"
|
||||
echo -e "mips64 use $Arch may have bug"
|
||||
;;
|
||||
"arm")
|
||||
Arch="arm"
|
||||
;;
|
||||
"aarch64")
|
||||
Arch="arm64"
|
||||
;;
|
||||
"powerpc")
|
||||
Arch="ppc"
|
||||
echo -e "error not support $Archt"
|
||||
EXIT 1
|
||||
;;
|
||||
"powerpc64")
|
||||
Arch="ppc64"
|
||||
echo -e "error not support $Archt"
|
||||
EXIT 1
|
||||
;;
|
||||
case "${Archt}" in
|
||||
i386)
|
||||
Arch=i386
|
||||
;;
|
||||
i686)
|
||||
Arch=i386
|
||||
;;
|
||||
x86)
|
||||
Arch=amd64
|
||||
;;
|
||||
mipsel)
|
||||
Arch=mipsle_softfloat
|
||||
;;
|
||||
mips)
|
||||
Arch=mips_softfloat
|
||||
;;
|
||||
mips64el)
|
||||
Arch=mips64le_softfloat
|
||||
;;
|
||||
mips64)
|
||||
Arch=mips64_softfloat
|
||||
;;
|
||||
arm)
|
||||
Arch=arm
|
||||
;;
|
||||
armeb)
|
||||
Arch=armeb
|
||||
;;
|
||||
aarch64)
|
||||
Arch=arm64
|
||||
;;
|
||||
*)
|
||||
echo -e "error not support $Archt if you can use offical release please issue a bug"
|
||||
EXIT 1
|
||||
@@ -221,13 +213,13 @@ doupdate_core(){
|
||||
}
|
||||
|
||||
EXIT(){
|
||||
rm /var/run/update_core 2>/dev/null
|
||||
rm /var/run/update_core rm -rf $LOCKU 2>/dev/null
|
||||
[ "$1" != "0" ] && touch /var/run/update_core_error
|
||||
exit $1
|
||||
}
|
||||
|
||||
main(){
|
||||
check_if_already_running
|
||||
# check_if_already_running
|
||||
check_latest_version $1
|
||||
}
|
||||
trap "EXIT 1" SIGTERM SIGINT
|
||||
|
||||
@@ -9,13 +9,13 @@ do
|
||||
/etc/init.d/AdGuardHome force_reload
|
||||
break
|
||||
fi
|
||||
ping -c 1 -W 1 -q 223.5.5.5 1>/dev/null 2>&1
|
||||
ping -c 1 -W 1 -q 202.108.22.5 1>/dev/null 2>&1
|
||||
if [ "$?" == "0" ]; then
|
||||
/etc/init.d/AdGuardHome force_reload
|
||||
break
|
||||
fi
|
||||
sleep 5
|
||||
ping -c 1 -W 1 -q www.github.com 1>/dev/null 2>&1
|
||||
ping -c 1 -W 1 -q www.google.com 1>/dev/null 2>&1
|
||||
if [ "$?" == "0" ]; then
|
||||
/etc/init.d/AdGuardHome force_reload
|
||||
break
|
||||
|
||||
Reference in New Issue
Block a user