Skip to content

Commit f282881

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 29329c9 commit f282881

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

Formula/t/technitium-dns.rb

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

0 commit comments

Comments
 (0)