mirror of
https://github.com/sirpdboy/sirpdboy-package.git
synced 2025-01-08 11:57:57 +08:00
upadguardhome
This commit is contained in:
parent
a177d12523
commit
1e078ddd70
@ -1,80 +1,88 @@
|
||||
#
|
||||
# Copyright (C) 2019 OpenWrt.org
|
||||
#
|
||||
# KFERMercer <KFER.Mercer@gmail.com>
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v3.
|
||||
# Copyright (C) 2015-2016 OpenWrt.org
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE.txt for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=AdGuardHome
|
||||
PKG_VERSION:=latest
|
||||
PKG_VERSION:=0.104.3
|
||||
PKG_RELEASE:=1
|
||||
|
||||
STRIP:=true
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_VERSION:=v$(PKG_VERSION)
|
||||
PKG_SOURCE_URL:=https://github.com/AdguardTeam/AdGuardHome
|
||||
PKG_MIRROR_HASH:=ec0d48413778267f4ac81091e58a88e5b5ee2f3c1ab48256ded3438bf171d311
|
||||
|
||||
ifeq ($(ARCH),i386)
|
||||
PKG_ARCH:=86
|
||||
endif
|
||||
PKG_LICENSE:=GPL-3.0-only
|
||||
PKG_LICENSE_FILES:=LICENSE.txt
|
||||
PKG_MAINTAINER:=Dobroslaw Kijowski <dobo90@gmail.com>
|
||||
|
||||
ifeq ($(ARCH),x86_64)
|
||||
PKG_ARCH:=amd64
|
||||
endif
|
||||
PKG_BUILD_DEPENDS:=golang/host node/host
|
||||
PKG_BUILD_PARALLEL:=1
|
||||
PKG_USE_MIPS16:=0
|
||||
|
||||
ifeq ($(ARCH),mipsel)
|
||||
PKG_ARCH:=mipsle
|
||||
endif
|
||||
PKG_CONFIG_DEPENDS:= \
|
||||
CONFIG_ADGUARDHOME_COMPRESS_GOPROXY \
|
||||
CONFIG_ADGUARDHOME_COMPRESS_UPX
|
||||
|
||||
ifeq ($(ARCH),mips)
|
||||
PKG_ARCH:=mipsle
|
||||
endif
|
||||
|
||||
ifeq ($(ARCH),arm64)
|
||||
PKG_ARCH:=arm64
|
||||
endif
|
||||
|
||||
ifeq ($(ARCH),aarch64)
|
||||
PKG_ARCH:=arm64
|
||||
endif
|
||||
|
||||
ifeq ($(ARCH),arm)
|
||||
ifeq ($(BOARD),bcm53xx)
|
||||
PKG_ARCH:=armv5
|
||||
else ifeq ($(BOARD),kirkwood)
|
||||
PKG_ARCH:=armv5
|
||||
else
|
||||
PKG_ARCH:=armv7
|
||||
endif
|
||||
endif
|
||||
|
||||
PKG_SOURCE:=AdGuardHome_linux_$(PKG_ARCH).tar.gz
|
||||
PKG_SOURCE_URL:=https://static.adguard.com/adguardhome/beta/
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/AdGuardHome_linux_$(PKG_ARCH)
|
||||
PKG_HASH:=skip
|
||||
GO_PKG:=github.com/AdguardTeam/AdGuardHome
|
||||
GO_PKG_EXCLUDES:=dhcpd/standalone
|
||||
GO_PKG_LDFLAGS:=-s -w
|
||||
GO_PKG_LDFLAGS_X:=main.version=$(PKG_VERSION) main.channel=release
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
include $(TOPDIR)/feeds/packages/lang/golang/golang-package.mk
|
||||
|
||||
define Package/$(PKG_NAME)
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
TITLE:=Network-wide ads & trackers blocking DNS server
|
||||
URL:=https://github.com/AdguardTeam/AdGuardHome
|
||||
define Package/AdGuardHome
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
TITLE:=Network-wide ads and trackers blocking DNS server
|
||||
URL:=https://github.com/AdguardTeam/AdGuardHome
|
||||
DEPENDS:=$(GO_ARCH_DEPENDS) +ca-bundle
|
||||
endef
|
||||
|
||||
|
||||
define Package/$(PKG_NAME)/description
|
||||
Network-wide ads & trackers blocking DNS server
|
||||
define Package/AdGuardHome/description
|
||||
Free and open source, powerful network-wide ads and trackers blocking DNS server.
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/config
|
||||
config ADGUARDHOME_COMPRESS_GOPROXY
|
||||
bool "Compiling with GOPROXY proxy"
|
||||
default n
|
||||
|
||||
config ADGUARDHOME_COMPRESS_UPX
|
||||
bool "Compress executable files with UPX"
|
||||
default n
|
||||
endef
|
||||
|
||||
ifeq ($(CONFIG_ADGUARDHOME_COMPRESS_GOPROXY),y)
|
||||
export GO111MODULE=on
|
||||
export GOPROXY=https://goproxy.io
|
||||
endif
|
||||
|
||||
define Build/Compile
|
||||
( \
|
||||
cd $(PKG_BUILD_DIR) ; \
|
||||
npm --prefix client ci ; \
|
||||
npm --prefix client run build-prod ; \
|
||||
GOOS=$$$$(go env GOOS) GOARCH=$$$$(go env GOARCH) GO111MODULE=off go get -v github.com/gobuffalo/packr/... ; \
|
||||
"$$$$(go env GOPATH)/bin/packr" -v -z -i $(PKG_BUILD_DIR)/home ; \
|
||||
$(call GoPackage/Build/Compile) ; \
|
||||
)
|
||||
ifeq ($(CONFIG_ADGUARDHOME_COMPRESS_UPX),y)
|
||||
$(STAGING_DIR_HOST)/bin/upx --lzma --best $(GO_PKG_BUILD_BIN_DIR)/AdGuardHome
|
||||
endif
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/install
|
||||
define Package/AdGuardHome/install
|
||||
$(call GoPackage/Package/Install/Bin,$(PKG_INSTALL_DIR))
|
||||
$(INSTALL_DIR) $(1)/usr/bin/AdGuardHome
|
||||
$(INSTALL_BIN) $(BUILD_DIR)/AdGuardHome/AdGuardHome $(1)/usr/bin/AdGuardHome/AdGuardHome
|
||||
$(INSTALL_BIN) $(GO_PKG_BUILD_BIN_DIR)/AdGuardHome $(1)/usr/bin/AdGuardHome/AdGuardHome
|
||||
$(INSTALL_DIR) $(1)/etc
|
||||
$(CP) -r ./files/etc $(1)/etc
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,$(PKG_NAME)))
|
||||
$(eval $(call GoBinPackage,AdGuardHome))
|
||||
$(eval $(call BuildPackage,AdGuardHome))
|
||||
|
@ -17,7 +17,7 @@ define Package/luci-app-adguardhome
|
||||
TITLE:=LuCI app for adguardhome
|
||||
PKG_MAINTAINER:=<https://github.com/rufengsuixing/luci-app-adguardhome>
|
||||
PKGARCH:=all
|
||||
DEPENDS:=+ca-certs +curl +wget-ssl
|
||||
DEPENDS:=+!wget&&!curl:wget
|
||||
endef
|
||||
|
||||
define Package/luci-app-adguardhome/description
|
||||
|
@ -27,34 +27,34 @@ 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;' 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=""
|
||||
if not fs.access(configpath) then
|
||||
e=e.." "..translate("no config")
|
||||
end
|
||||
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")
|
||||
else
|
||||
local version=uci:get("AdGuardHome","AdGuardHome","version")
|
||||
local testtime=fs.stat(binpath,"mtime")
|
||||
if testtime~=tonumber(binmtime) or version==nil then
|
||||
-- local tmp=luci.sys.exec(binpath.." --version | grep -m 1 -E ' [0-9.]+' -o ")
|
||||
-- version=string.sub(tmp, 1)
|
||||
-- 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)
|
||||
uci:save("AdGuardHome")
|
||||
uci:commit("AdGuardHome")
|
||||
end
|
||||
e=version..e
|
||||
end
|
||||
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("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
|
||||
@ -310,7 +310,7 @@ function m.on_commit(map)
|
||||
uci:set("AdGuardHome", "AdGuardHome", "ucitracktest", "2")
|
||||
end
|
||||
end
|
||||
uci:save("AdGuardHome")
|
||||
uci:commit("AdGuardHome")
|
||||
end
|
||||
end
|
||||
return m
|
||||
|
@ -1,6 +1,7 @@
|
||||
config AdGuardHome 'AdGuardHome'
|
||||
option enabled '0'
|
||||
option httpport '3000'
|
||||
option redirect 'none'
|
||||
option configpath '/etc/AdGuardHome.yaml'
|
||||
option workdir '/usr/bin/AdGuardHome'
|
||||
option logfile '/tmp/AdGuardHome.log'
|
||||
|
@ -49,7 +49,9 @@ 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
|
||||
uci set dhcp.@dnsmasq[0].resolvfile=/tmp/resolv.conf.auto 2>/dev/null
|
||||
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 delete dhcp.@dnsmasq[0].noresolv 2>/dev/null
|
||||
fi
|
||||
uci commit dhcp
|
||||
@ -68,29 +70,14 @@ 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
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
[ "$ipv6_server" == 0 ] && return
|
||||
|
||||
[ "$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
|
||||
}
|
||||
|
||||
clear_iptable()
|
||||
@ -99,26 +86,34 @@ clear_iptable()
|
||||
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
|
||||
|
||||
if [ "$ipv6_server" == 0 ]; then
|
||||
return
|
||||
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
|
||||
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() {
|
||||
@ -183,7 +178,7 @@ rm_port53()
|
||||
config_editor "dns.port" "$dnsmasq_port" "$configpath"
|
||||
uci set dhcp.@dnsmasq[0].port="53"
|
||||
uci commit dhcp
|
||||
/etc/init.d/dnsmasq reload
|
||||
/etc/init.d/dnsmasq restart
|
||||
}
|
||||
|
||||
use_port53()
|
||||
@ -203,7 +198,7 @@ use_port53()
|
||||
config_editor "dns.port" "53" "$configpath"
|
||||
uci set dhcp.@dnsmasq[0].port="$AdGuardHome_PORT"
|
||||
uci commit dhcp
|
||||
/etc/init.d/dnsmasq reload
|
||||
/etc/init.d/dnsmasq restart
|
||||
}
|
||||
do_redirect()
|
||||
{
|
||||
@ -232,6 +227,7 @@ _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
|
||||
@ -239,7 +235,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 "$old_port" "$ipv6_server"
|
||||
clear_iptable
|
||||
elif [ "$old_redirect" == "dnsmasq-upstream" ]; then
|
||||
stop_forward_dnsmasq "$old_port"
|
||||
elif [ "$old_redirect" == "exchange" ]; then
|
||||
@ -248,7 +244,7 @@ _do_redirect()
|
||||
fi
|
||||
elif [ "$old_enabled" = "1" -a "$enabled" = "1" ]; then
|
||||
if [ "$old_redirect" == "redirect" -a "$old_port" != "0" ]; then
|
||||
clear_iptable "$old_port" "$ipv6_server"
|
||||
clear_iptable
|
||||
fi
|
||||
fi
|
||||
uci delete AdGuardHome.@AdGuardHome[0].old_redirect 2>/dev/null
|
||||
|
Loading…
Reference in New Issue
Block a user