class PcapDnsproxy < Formula desc "Powerful DNS proxy designed to anti DNS spoofing" homepage "https://github.com/chengr28/Pcap_DNSProxy" url "https://github.com/chengr28/Pcap_DNSProxy/archive/v0.4.9.0.tar.gz" sha256 "4c7854874d7c06b5fcbdb8cb22f58eedb124721670c042eb7676d76987e97b34" head "https://github.com/chengr28/Pcap_DNSProxy.git" bottle do sha256 "645cf86c499459e461357fe0a4d41cc451aa35b9b61dfc956bf525aa0b7814b6" => :sierra sha256 "819294a6e3ec1cb7b5738bec6b1d39178707deb5be3ab87bbeda6dbbbf68c545" => :el_capitan end depends_on :macos => :el_capitan depends_on :xcode => :build depends_on "libsodium" depends_on "openssl@1.1" def install (buildpath/"Source/Dependency/LibSodium").install_symlink Formula["libsodium"].opt_lib/"libsodium.a" => "LibSodium_macOS.a" (buildpath/"Source/Dependency/OpenSSL").install_symlink Formula["openssl@1.1"].opt_lib/"libssl.a" => "LibSSL_macOS.a" (buildpath/"Source/Dependency/OpenSSL").install_symlink Formula["openssl@1.1"].opt_lib/"libcrypto.a" => "LibCrypto_macOS.a" xcodebuild "-project", "./Source/Pcap_DNSProxy.xcodeproj", "-target", "Pcap_DNSProxy", "-configuration", "Release", "SYMROOT=build" bin.install "Source/build/Release/Pcap_DNSProxy" (etc/"pcap_DNSproxy").install Dir["Source/Auxiliary/ExampleConfig/*.{ini,txt}"] prefix.install "Source/Auxiliary/ExampleConfig/pcap_dnsproxy.service.plist" end plist_options :startup => true, :manual => "sudo #{HOMEBREW_PREFIX}/opt/pcap_dnsproxy/bin/Pcap_DNSProxy -c #{HOMEBREW_PREFIX}/etc/pcap_DNSproxy/" test do (testpath/"pcap_DNSproxy").mkpath cp Dir[etc/"pcap_DNSproxy/*"], testpath/"pcap_DNSproxy/" inreplace testpath/"pcap_DNSproxy/Config.ini" do |s| s.gsub! /^Direct Request.*/, "Direct Request = IPv4 + IPv6" s.gsub! /^Operation Mode.*/, "Operation Mode = Proxy" s.gsub! /^Listen Port.*/, "Listen Port = 9999" end pid = fork { exec bin/"Pcap_DNSProxy", "-c", testpath/"pcap_DNSproxy/" } begin system "dig", "google.com", "@127.0.0.1", "-p", "9999", "+short" ensure Process.kill 9, pid Process.wait pid end end end