From 4cbac9faaef46566f7ab92d2f31fef43033d8e57 Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 16 Jun 2015 23:03:27 +0800 Subject: [PATCH] Pcap_DNSProxy 0.4.2 (new formula) Closes Homebrew/homebrew#40381. Signed-off-by: Xu Cheng --- Formula/pcap_dnsproxy.rb | 65 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 Formula/pcap_dnsproxy.rb diff --git a/Formula/pcap_dnsproxy.rb b/Formula/pcap_dnsproxy.rb new file mode 100644 index 0000000000..95f7a4904a --- /dev/null +++ b/Formula/pcap_dnsproxy.rb @@ -0,0 +1,65 @@ +class PcapDnsproxy < Formula + desc "A 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.2.tar.gz" + sha256 "0737b16283e84bc94f63066f448ba84416141b8d5a86b5e01f1f97164d9d44f2" + head "https://github.com/chengr28/Pcap_DNSProxy.git" + + depends_on :xcode => :build + depends_on "libsodium" => :build + + def install + rm Dir[buildpath/"Source/LibSodium/*"] + ln_s "#{Formula["libsodium"].opt_lib}/libsodium.a", "#{buildpath}/Source/LibSodium/LibSodium_Mac.a" + ln_s Dir[Formula["libsodium"].opt_include/"*"], "#{buildpath}/Source/LibSodium/" + xcodebuild "-project", "./Source/KeyPairGenerator.xcodeproj", "-target", "KeyPairGenerator", "-configuration", "Release", "SYMROOT=build" + xcodebuild "-project", "./Source/Pcap_DNSProxy.xcodeproj", "-target", "Pcap_DNSProxy", "-configuration", "Release", "SYMROOT=build" + + bin.install "Source/build/Release/KeyPairGenerator" + bin.install "Source/build/Release/Pcap_DNSProxy" + (etc/"pcap_DNSproxy").install Dir["Source/ExampleConfig/*.{ini,txt}"] + end + + test do + mkdir testpath/"pcap_dnsproxy" + cp Dir[etc/"pcap_dnsproxy/*"], testpath/"pcap_dnsproxy/" + inreplace testpath/"pcap_dnsproxy/Config.ini" do |s| + s.gsub! /^Hosts Only.*/, "Hosts Only = 1" + 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 + + plist_options :startup => true, :manual => "sudo #{HOMEBREW_PREFIX}/opt/pcap_dnsproxy/bin/Pcap_DNSProxy -c #{HOMEBREW_PREFIX}/etc/pcap_dnsproxy/" + + def plist; <<-EOS.undent + + + + + Label + #{plist_name} + ProgramArguments + + #{opt_bin}/Pcap_DNSProxy + -c + #{etc}/pcap_dnsproxy/ + + RunAtLoad + + KeepAlive + + SuccessfulExit + + + + + EOS + end +end