Skip to content

Instantly share code, notes, and snippets.

@zhenhappy
Last active May 28, 2018 08:54
Show Gist options
  • Save zhenhappy/26f611badd69bd0ca69338148707923c to your computer and use it in GitHub Desktop.
Save zhenhappy/26f611badd69bd0ca69338148707923c to your computer and use it in GitHub Desktop.
pcap_dnsproxy.rb
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.4.tar.gz"
sha256 "9d2f6026d05dbfb8795cec0a4341b7d947c6abe4280353bdcf4793679ec296f2"
head "https://github.com/chengr28/Pcap_DNSProxy.git"
bottle do
rebuild 1
sha256 "dece914ff9c114edff0392682722f0e88776c80f653ebe0365e37ccda289e2b7" => :high_sierra
sha256 "0862220302a6c7500de591113cc52ba6a9fe958726147c1a515aba3ecdefbbda" => :sierra
sha256 "956bd0e1faba69ed5b212f037c453b5648b39d16bd6ee81c5e79da821f613b8e" => :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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment