net-dns/blocky: Fast and lightweight DNS proxy as ad-blocker

Supports DoH, DoT and prometheus+grafana integration with very versatile
cli and configuration options

Signed-off-by: Rahil Bhimjiani <me@rahil.rocks>
This commit is contained in:
Rahil Bhimjiani
2024-01-01 11:23:54 +05:30
parent 455aae69ed
commit 26fd689d60
10 changed files with 2554 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
# Copyright 2019-2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
inherit acct-group
DESCRIPTION="A group for net-dns/blocky"
ACCT_GROUP_ID="69"

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE pkgmetadata SYSTEM "https://www.gentoo.org/dtd/metadata.dtd">
<pkgmetadata>
<maintainer type="person">
<email>me@rahil.rocks</email>
<name>Rahil Bhimjiani</name>
</maintainer>
</pkgmetadata>

View File

@@ -0,0 +1,13 @@
# Copyright 2019-2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
inherit acct-user
DESCRIPTION="A user for net-dns/blocky"
ACCT_USER_ID="100"
ACCT_USER_GROUPS=( "blocky" )
acct-user_add_deps

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE pkgmetadata SYSTEM "https://www.gentoo.org/dtd/metadata.dtd">
<pkgmetadata>
<maintainer type="person">
<email>me@rahil.rocks</email>
<name>Rahil Bhimjiani</name>
</maintainer>
</pkgmetadata>

3
net-dns/blocky/Manifest Normal file
View File

@@ -0,0 +1,3 @@
DIST blocky-0.22-deps.tar.xz 163869124 BLAKE2B e98614feaeb11604866d08003147871096c993cdb90c85bba46ea999a339570ca1500a80bddee202595372ec5d22baa6ec0345d8cf50ffee6d61dd8d6495d49f SHA512 883e5dd66cf974c6d8c73a94c7677d5003ceb7a3ba68001c2d9d36e1e4d1ea64f0818d30240fe77f192ad3f95ede93127bed9adc9647da07a9b9bebc958ffd33
DIST blocky-0.22-docs.tar.gz 5639822 BLAKE2B e177790deb7493f84d8217661e4e4296004a9db7e00ff8d37dbd3c4ed8b7ba0a7cf431067c103f25784e46ca7a8bf80532cdd8f305f3e4ce119890027f0eb186 SHA512 3eed0ff726479826fbefb4140c36bb26825124134d1fbbecf74a31b2fbdde993630adc645ea2e582ce8d415736cc85b20f64a835c87da98700b715c03d368e75
DIST blocky-0.22.tar.gz 712644 BLAKE2B d74881026421337a0fc32a6af2cf6bff736e0130ac599cd80714f0cafff1e81864e0327bc773f8377106421642cf545b76407fca94f07425c428ff8512a7113b SHA512 928ba882cb567f80b9b00c1ab74ba2fba0324b9e5fb6439789d50d8fd438a26f84772d36f91ef9c3a2351c798a399c15aa1b69927a2da11795edd576b7bae6a4

View File

@@ -0,0 +1,104 @@
# Copyright 1999-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
inherit fcaps go-module systemd shell-completion
DESCRIPTION="Fast and lightweight DNS proxy as ad-blocker with many features written in Go"
HOMEPAGE="https://github.com/0xERR0R/blocky/"
DOCUMENTATION_COMMIT=9c6a86eb163e758686c5d6d4d5259deb086a8aa9
if [[ ${PV} == 9999* ]]; then
inherit git-r3
EGIT_REPO_URI="https://github.com/0xERR0R/blocky.git"
else
SRC_URI="
https://github.com/0xERR0R/blocky/archive/v${PV}.tar.gz -> ${P}.tar.gz
https://github.com/rahilarious/gentoo-distfiles/releases/download/${P}/deps.tar.xz -> ${P}-deps.tar.xz
doc? ( https://github.com/0xERR0R/blocky/archive/${DOCUMENTATION_COMMIT}.tar.gz -> ${P}-docs.tar.gz )
"
KEYWORDS="~amd64"
fi
# main
LICENSE="Apache-2.0"
# deps
LICENSE+=" AGPL-3 BSD-2 BSD ISC MIT MPL-2.0"
SLOT="0"
IUSE="doc"
# RESTRICT="test"
RDEPEND="
acct-user/blocky
acct-group/blocky
"
PATCHES=(
"${FILESDIR}"/disable-failed-tests-0.22.patch
)
FILECAPS=(
-m 755 'cap_net_bind_service=+ep' usr/bin/"${PN}"
)
src_unpack() {
if [[ ${PV} == 9999* ]]; then
git-r3_src_unpack
go-module_live_vendor
if use doc; then
EGIT_BRANCH="gh-pages"
EGIT_CHECKOUT_DIR="${WORKDIR}/${P}-doc"
git-r3_src_unpack
fi
else
go-module_src_unpack
fi
}
src_compile() {
[[ ${PV} != 9999* ]] && export VERSION="${PV}"
# mimicking project's Dockerfile
emake GO_SKIP_GENERATE=yes GO_BUILD_FLAGS="-tags static -v " build
local shell
for shell in bash fish zsh; do
bin/"${PN}" completion "${shell}" > "${PN}"."${shell}" || die
done
}
src_test() {
# mimcking make test
ego run github.com/onsi/ginkgo/v2/ginkgo --label-filter="!e2e" --coverprofile=coverage.txt --covermode=atomic --cover -r -p
ego tool cover -html coverage.txt -o coverage.html
}
src_install() {
# primary program
dobin bin/"${PN}"
# secondary supplements
insinto /etc/"${PN}"
newins docs/config.yml config.yml.sample
newbashcomp "${PN}".bash "${PN}"
dofishcomp "${PN}".fish
newzshcomp "${PN}".zsh _"${PN}"
# TODO openrc services
systemd_newunit "${FILESDIR}"/blocky-0.22.service "${PN}".service
# docs
einstalldocs
if use doc; then
if [[ ${PV} == 9999* ]]; then
dodoc -r ../"${P}"-doc/main/*
else
dodoc -r ../"${PN}"-"${DOCUMENTATION_COMMIT}"/v"${PV}"/*
fi
fi
}

View File

@@ -0,0 +1,104 @@
# Copyright 1999-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
inherit fcaps go-module systemd shell-completion
DESCRIPTION="Fast and lightweight DNS proxy as ad-blocker with many features written in Go"
HOMEPAGE="https://github.com/0xERR0R/blocky/"
DOCUMENTATION_COMMIT=9c6a86eb163e758686c5d6d4d5259deb086a8aa9
if [[ ${PV} == 9999* ]]; then
inherit git-r3
EGIT_REPO_URI="https://github.com/0xERR0R/blocky.git"
else
SRC_URI="
https://github.com/0xERR0R/blocky/archive/v${PV}.tar.gz -> ${P}.tar.gz
https://github.com/rahilarious/gentoo-distfiles/releases/download/${P}/deps.tar.xz -> ${P}-deps.tar.xz
doc? ( https://github.com/0xERR0R/blocky/archive/${DOCUMENTATION_COMMIT}.tar.gz -> ${P}-docs.tar.gz )
"
KEYWORDS="~amd64"
fi
# main
LICENSE="Apache-2.0"
# deps
LICENSE+=" AGPL-3 BSD-2 BSD ISC MIT MPL-2.0"
SLOT="0"
IUSE="doc"
RESTRICT="test"
RDEPEND="
acct-user/blocky
acct-group/blocky
"
# PATCHES=(
# "${FILESDIR}"/disable-failed-tests-0.22.patch
# )
FILECAPS=(
-m 755 'cap_net_bind_service=+ep' usr/bin/"${PN}"
)
src_unpack() {
if [[ ${PV} == 9999* ]]; then
git-r3_src_unpack
go-module_live_vendor
if use doc; then
EGIT_BRANCH="gh-pages"
EGIT_CHECKOUT_DIR="${WORKDIR}/${P}-doc"
git-r3_src_unpack
fi
else
go-module_src_unpack
fi
}
src_compile() {
[[ ${PV} != 9999* ]] && export VERSION="${PV}"
# mimicking project's Dockerfile
emake GO_SKIP_GENERATE=yes GO_BUILD_FLAGS="-tags static -v " build
local shell
for shell in bash fish zsh; do
bin/"${PN}" completion "${shell}" > "${PN}"."${shell}" || die
done
}
src_test() {
# mimcking make test
ego run github.com/onsi/ginkgo/v2/ginkgo --label-filter="!e2e" --coverprofile=coverage.txt --covermode=atomic --cover -r -p
ego tool cover -html coverage.txt -o coverage.html
}
src_install() {
# primary program
dobin bin/"${PN}"
# secondary supplements
insinto /etc/"${PN}"
newins docs/config.yml config.yml.sample
newbashcomp "${PN}".bash "${PN}"
dofishcomp "${PN}".fish
newzshcomp "${PN}".zsh _"${PN}"
# TODO openrc services
systemd_newunit "${FILESDIR}"/blocky-0.22.service "${PN}".service
# docs
einstalldocs
if use doc; then
if [[ ${PV} == 9999* ]]; then
dodoc -r ../"${P}"-doc/main/*
else
dodoc -r ../"${PN}"-"${DOCUMENTATION_COMMIT}"/v"${PV}"/*
fi
fi
}

View File

@@ -0,0 +1,16 @@
[Unit]
Description=Fast and lightweight DNS proxy as ad-blocker
Documentation=https://0xerr0r.github.io/blocky/
After=network-online.target
Wants=network-online.target
[Service]
CapabilityBoundingSet=CAP_NET_BIND_SERVICE
AmbientCapabilities=CAP_NET_BIND_SERVICE
NoNewPrivileges=true
User=blocky
ExecStart=/usr/bin/blocky --config /etc/blocky/config.yml
Restart=on-failure
[Install]
WantedBy=multi-user.target

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE pkgmetadata SYSTEM "https://www.gentoo.org/dtd/metadata.dtd">
<pkgmetadata>
<maintainer type="person">
<email>me@rahil.rocks</email>
<name>Rahil Bhimjiani</name>
</maintainer>
<longdescription>
Blocky is a DNS proxy and ad-blocker alternative to Pi-Hole and AdGuard Home written in Go with support for DNSSEC, DNS over HTTPS (DoH), DNS over TLS (DoT), metrics via prometheus-grafana, REST api, per client per group blacklists and whitelists, custom domains, conditional forwarding and simple YAML config.
</longdescription>
<upstream>
<remote-id type="github">0xERR0R/blocky</remote-id>
<bugs-to>https://github.com/0xERR0R/blocky/issues</bugs-to>
<doc>https://0xerr0r.github.io/blocky/</doc>
</upstream>
</pkgmetadata>