homebrew-core/Formula/frps.rb

79 lines
2.2 KiB
Ruby
Raw Normal View History

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.0",
:revision => "95444ea46b40ca4b7f636a66530f48e8b68969bf"
2019-04-11 17:49:33 +00:00
bottle do
cellar :any_skip_relocation
2019-04-26 00:28:04 +00:00
sha256 "c26454e010b8225d946598deced88fd26378f3ff316aad4cdad0709b06e29fc1" => :mojave
sha256 "f22cdfe3ced0f9f37eb865c853ced54f08f8ae742da09c7de9ad0c8088ff1e06" => :high_sierra
sha256 "858cb03f5a4c8d128749d7bce7bb54e509edaccd1cd31b63d0d84bf9f7a04a78" => :sierra
2019-04-11 17:49:33 +00:00
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