homebrew-core/Formula/frpc.rb
2019-09-06 17:12:08 +02:00

72 lines
2.5 KiB
Ruby

class Frpc < Formula
desc "Client 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.29.0",
:revision => "e62d9a52429f54dee8df1c42f2d4bad7a267b05d"
bottle do
cellar :any_skip_relocation
sha256 "2ed284c0f7f2c864672071fec6995264b3057e4a77c310bf27216e10e34f6293" => :mojave
sha256 "6fa70559da5b933edb589755a0c07d33b8c6b6794737356b7a8e9f3dba89f9a8" => :high_sierra
sha256 "9130a28e18506a287e41c58b82e50f94fc6b706e2e2a94ed028ec0c17bb296b6" => :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", "frpc"
bin.install "bin/frpc"
etc.install "conf/frpc.ini" => "frp/frpc.ini"
etc.install "conf/frpc_full.ini" => "frp/frpc_full.ini"
prefix.install_metafiles
end
end
plist_options :manual => "frpc -c #{HOMEBREW_PREFIX}/etc/frp/frpc.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}/frpc</string>
<string>-c</string>
<string>#{etc}/frp/frpc.ini</string>
</array>
<key>StandardErrorPath</key>
<string>#{var}/log/frpc.log</string>
<key>StandardOutPath</key>
<string>#{var}/log/frpc.log</string>
</dict>
</plist>
EOS
end
test do
system bin/"frpc", "-v"
assert_match "Commands", shell_output("#{bin}/frpc help")
assert_match "local_port", shell_output("#{bin}/frpc http", 1)
assert_match "local_port", shell_output("#{bin}/frpc https", 1)
assert_match "local_port", shell_output("#{bin}/frpc stcp", 1)
assert_match "local_port", shell_output("#{bin}/frpc tcp", 1)
assert_match "local_port", shell_output("#{bin}/frpc udp", 1)
assert_match "local_port", shell_output("#{bin}/frpc xtcp", 1)
assert_match "admin_port", shell_output("#{bin}/frpc status -c #{etc}/frp/frpc.ini", 1)
assert_match "admin_port", shell_output("#{bin}/frpc reload -c #{etc}/frp/frpc.ini", 1)
end
end