homebrew-core/Formula/frps.rb
2019-07-15 08:38:29 +08:00

78 lines
2.2 KiB
Ruby

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.27.1",
:revision => "e611c44dea69b54b010f370e040fe5fef97fd9e6"
bottle do
cellar :any_skip_relocation
sha256 "81c9388d1db926d45386be606d008f00fe9bb63cfea6084c67563ca1bb294f1d" => :mojave
sha256 "99bf2d38a95f6c5c7725ebd8c8f86b204be0ad7df0a4d86305390a6b865bc63a" => :high_sierra
sha256 "2f154806eb9faf8f636d4bf3078c11b54f37f3751fc081fcb97dfe750146e3a5" => :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
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>#{plist_name}</string>
<key>KeepAlive</key>
<true/>
<key>ProgramArguments</key>
<array>
<string>#{opt_bin}/frps</string>
<string>-c</string>
<string>#{etc}/frp/frps.ini</string>
</array>
<key>StandardErrorPath</key>
<string>#{var}/log/frps.log</string>
<key>StandardOutPath</key>
<string>#{var}/log/frps.log</string>
</dict>
</plist>
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