class DnscryptProxy < Formula desc "Secure communications between a client and a DNS resolver" homepage "https://github.com/jedisct1/dnscrypt-proxy" url "https://github.com/jedisct1/dnscrypt-proxy/archive/2.0.27.tar.gz" sha256 "a501f44af39cb43e00489ef9e6678aa8adba2bc98f9042dd61ce60e9ad074d5a" head "https://github.com/jedisct1/dnscrypt-proxy.git" bottle do cellar :any_skip_relocation sha256 "e7be3f4e287c165d51a018ecdfe159d5751b5c796f0b996d30f3677cd6a49641" => :catalina sha256 "6b0137364980183f7e36c4be428b997827d96f42e05ed1d9778a34f87ea74dfe" => :mojave sha256 "a66c452c3638f7ee9996758ca414f45615613621c053a6fb31308b9c15ccda9d" => :high_sierra sha256 "fa526ef38495dd7dbb1624e74b18236629ac28a5c0952d4282258ac5769465e2" => :sierra end depends_on "go" => :build def install ENV["GOPATH"] = buildpath prefix.install_metafiles dir = buildpath/"src/github.com/jedisct1/dnscrypt-proxy" dir.install buildpath.children cd dir/"dnscrypt-proxy" do system "go", "build", "-ldflags", "-X main.version=#{version}", "-o", sbin/"dnscrypt-proxy" pkgshare.install Dir["example*"] etc.install pkgshare/"example-dnscrypt-proxy.toml" => "dnscrypt-proxy.toml" end end def caveats; <<~EOS After starting dnscrypt-proxy, you will need to point your local DNS server to 127.0.0.1. You can do this by going to System Preferences > "Network" and clicking the "Advanced..." button for your interface. You will see a "DNS" tab where you can click "+" and enter 127.0.0.1 in the "DNS Servers" section. By default, dnscrypt-proxy runs on localhost (127.0.0.1), port 53, balancing traffic across a set of resolvers. If you would like to change these settings, you will have to edit the configuration file: #{etc}/dnscrypt-proxy.toml To check that dnscrypt-proxy is working correctly, open Terminal and enter the following command. Replace en1 with whatever network interface you're using: sudo tcpdump -i en1 -vvv 'port 443' You should see a line in the result that looks like this: resolver.dnscrypt.info EOS end plist_options :startup => true def plist; <<~EOS Label #{plist_name} KeepAlive RunAtLoad ProgramArguments #{opt_sbin}/dnscrypt-proxy -config #{etc}/dnscrypt-proxy.toml UserName root StandardErrorPath /dev/null StandardOutPath /dev/null EOS end test do config = "-config #{etc}/dnscrypt-proxy.toml" output = shell_output("#{sbin}/dnscrypt-proxy #{config} -list 2>&1") assert_match "public-resolvers.md] loaded", output end end