Skip to content

Commit c9f1eb7

Browse files
committed
technitium-dns 13.5.0 (new formula)
Add a formula for [Technitium DNS](https://github.com/TechnitiumSoftware/DnsServer), a self-hosted DNS server for privacy & security which can also block ads & malware at the DNS level. The code owner approves this contribution: TechnitiumSoftware/DnsServer#1294
1 parent 97715bd commit c9f1eb7

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed

Diff for: Formula/t/technitium-dns.rb

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
class TechnitiumDns < Formula
2+
desc "Self host a DNS server for privacy & security"
3+
homepage "https://technitium.com/dns/"
4+
url "https://github.com/TechnitiumSoftware/DnsServer/archive/refs/tags/v13.5.0.tar.gz"
5+
sha256 "7a5f47af4c938c5983e415547b777f853ede5ada8837012c8b5e8e36df1a380e"
6+
license "GPL-3.0-or-later"
7+
8+
depends_on "dotnet@8"
9+
depends_on "libmsquic"
10+
11+
resource "TechnitiumLibrary" do
12+
url "https://github.com/TechnitiumSoftware/TechnitiumLibrary/archive/refs/tags/dns-server-v13.5.0.tar.gz"
13+
sha256 "8e0f3200ad6ee6a1ab346a7224a1bc538f6b3dc1b660cd8bb725d0dc09fa2bf9"
14+
end
15+
16+
def install
17+
# See https://github.com/TechnitiumSoftware/DnsServer/blob/master/build.md#build-instructions
18+
dotnet = Formula["dotnet@8"]
19+
mkdir_p "DnsServer"
20+
mv Dir.glob("*").reject { |f| f == "DnsServer" }, "DnsServer"
21+
resource("TechnitiumLibrary").stage do
22+
system dotnet.opt_bin/"dotnet", "build",
23+
"TechnitiumLibrary.ByteTree/TechnitiumLibrary.ByteTree.csproj",
24+
"-c", "Release"
25+
system dotnet.opt_bin/"dotnet", "build",
26+
"TechnitiumLibrary.Net/TechnitiumLibrary.Net.csproj",
27+
"-c", "Release"
28+
cp_r ".", buildpath/"TechnitiumLibrary"
29+
end
30+
system dotnet.opt_bin/"dotnet", "publish", "DnsServer/DnsServerApp/DnsServerApp.csproj", "-c", "Release"
31+
libexec.install Dir["DnsServer/DnsServerApp/bin/Release/publish/*"]
32+
end
33+
34+
service do
35+
dotnet = Formula["dotnet@8"]
36+
run [dotnet.opt_bin/"dotnet", opt_libexec/"DnsServerApp.dll", etc/"technitium-dns"]
37+
keep_alive true
38+
error_log_path var/"log/technitium-dns.log"
39+
log_path var/"log/technitium-dns.log"
40+
working_dir var
41+
end
42+
43+
test do
44+
# Start the DNS server
45+
dotnet = Formula["dotnet@8"]
46+
pid = fork do
47+
Dir.mktmpdir do |tmpdir|
48+
exec "#{dotnet.opt_bin}/dotnet", libexec/"DnsServerApp.dll", tmpdir
49+
end
50+
end
51+
sleep 2 # Give the server time to start
52+
53+
begin
54+
# Use `dig` to resolve "localhost"
55+
output = shell_output("dig @127.0.0.1 localhost 2>&1")
56+
assert_match "ANSWER SECTION", output
57+
assert_match "localhost.", output
58+
ensure
59+
# Kill the DNS server process
60+
Process.kill("KILL", pid)
61+
Process.wait(pid)
62+
end
63+
end
64+
end

0 commit comments

Comments
 (0)