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.31.1", :revision => "f480160e2d22b9bbca2590660b50d69a1c5059bc" bottle do cellar :any_skip_relocation sha256 "3551aae31268fe7098de45e16c7036d8a829008d0d40aac5c2731b6966149340" => :catalina sha256 "2c17f6bb66cda46d12d7287234bdbfa361ef19c1508196ef6c29173abda37da1" => :mojave sha256 "f6a536fcda06606c49dc93398b94f8960fb1476fc0aee693440cd36431c37241" => :high_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