class Stubby < Formula desc "DNS privacy enabled stub resolver service based on getdns" homepage "https://dnsprivacy.org/wiki/display/DP/DNS+Privacy+Daemon+-+Stubby" url "https://github.com/getdnsapi/stubby/archive/v0.2.5.tar.gz" sha256 "56ee63f4b9ee00476a168e6ba5614f6830f93e89baa305c2d38577b2e39eae5b" head "https://github.com/getdnsapi/stubby.git", :branch => "develop" bottle do sha256 "b4865e26e583345914fde67a883816a45aa5e41ad3aa57ca593a9aa127c21def" => :mojave sha256 "2bf0b1276231e0528dc0cacd7efb4145c719a4f01d14a9ad2a841c558d889ed5" => :high_sierra sha256 "69ff4ee005474914a7b3cd1dd5cda0d26c20cdd6c7bcdaa624411e2511ea620e" => :sierra end depends_on "autoconf" => :build depends_on "automake" => :build depends_on "libtool" => :build depends_on "getdns" depends_on "libyaml" def install system "autoreconf", "-fiv" system "./configure", "--disable-dependency-tracking", "--disable-silent-rules", "--prefix=#{prefix}", "--sysconfdir=#{etc}" system "make", "install" end plist_options :startup => true, :manual => "sudo stubby -C #{HOMEBREW_PREFIX}/etc/stubby/stubby.yml" def plist; <<~EOS Label #{plist_name} KeepAlive RunAtLoad ProgramArguments #{opt_bin}/stubby -C #{etc}/stubby/stubby.yml -l StandardErrorPath #{var}/log/stubby/stubby.log StandardOutPath #{var}/log/stubby/stubby.log EOS end test do assert_predicate etc/"stubby/stubby.yml", :exist? (testpath/"stubby_test.yml").write <<~EOS resolution_type: GETDNS_RESOLUTION_STUB dns_transport_list: - GETDNS_TRANSPORT_TLS - GETDNS_TRANSPORT_UDP - GETDNS_TRANSPORT_TCP listen_addresses: - 127.0.0.1@5553 idle_timeout: 0 upstream_recursive_servers: - address_data: 145.100.185.15 - address_data: 145.100.185.16 - address_data: 185.49.141.37 EOS output = shell_output("#{bin}/stubby -i -C stubby_test.yml") assert_match "bindata for 145.100.185.15", output pid = fork do exec "#{bin}/stubby", "-C", testpath/"stubby_test.yml" end begin sleep 2 output = shell_output("dig @127.0.0.1 -p 5553 getdnsapi.net") assert_match "status: NOERROR", output ensure Process.kill 9, pid Process.wait pid end end end