class Frps < Formula desc "Server app of fast reverse proxy to expose a local server to the internet" homepage "https://github.com/fatedier/frp" url "https://github.com/fatedier/frp.git", :tag => "v0.26.0", :revision => "6a7efc81c9fcd410ba603573cdbe501056b1b04a" bottle do cellar :any_skip_relocation sha256 "eaf2b89d0afa6b2b3e9ffc3f69a93eb0c9d8ecf4c3ec5d2aea207f28f515a72c" => :mojave sha256 "9cf61e02eba03ed84b5af4e329b301c6bcd34c8284bce3ce2d0f2bc1c8b96125" => :high_sierra sha256 "4cceafca479dc0341de2d0b2fa9ccd767030939e36ab8745633481d06d020177" => :sierra end depends_on "go" => :build def install ENV["GOPATH"] = buildpath contents = Dir["{*,.git,.gitignore}"] (buildpath/"src/github.com/fatedier/frp").install contents (buildpath/"bin").mkpath (etc/"frp").mkpath cd "src/github.com/fatedier/frp" do system "make", "frps" bin.install "bin/frps" etc.install "conf/frps.ini" => "frp/frps.ini" etc.install "conf/frps_full.ini" => "frp/frps_full.ini" prefix.install_metafiles end end plist_options :manual => "frps -c #{HOMEBREW_PREFIX}/etc/frp/frps.ini" def plist; <<~EOS Label #{plist_name} KeepAlive ProgramArguments #{opt_bin}/frps -c #{etc}/frp/frps.ini StandardErrorPath #{var}/log/frps.log StandardOutPath #{var}/log/frps.log EOS end test do system bin/"frps", "-v" assert_match "Flags", shell_output("#{bin}/frps --help") begin read, write = IO.pipe pid = fork do exec bin/"frps", :out => write end sleep 3 output = read.gets assert_match "frps tcp listen on", output ensure Process.kill(9, pid) Process.wait(pid) end end end