jackett 0.22.1382
[Homebrew/homebrew-core.git] / Formula / c / chisel-tunnel.rb
blob898bbcca22978d9d182295cceb4f1329c86a3d74
1 class ChiselTunnel < Formula
2   desc "Fast TCP/UDP tunnel over HTTP"
3   homepage "https://github.com/jpillora/chisel"
4   url "https://github.com/jpillora/chisel/archive/refs/tags/v1.10.1.tar.gz"
5   sha256 "85d121087ea3e1139f63eaa389642bd6d8c2584728ec80d16315b17410844269"
6   license "MIT"
7   head "https://github.com/jpillora/chisel.git", branch: "master"
9   bottle do
10     rebuild 1
11     sha256 cellar: :any_skip_relocation, arm64_sequoia: "05ab3b695c06c0f9228bfd895ef79863a8e78a6b68e96b06774e703ac9075bd5"
12     sha256 cellar: :any_skip_relocation, arm64_sonoma:  "05ab3b695c06c0f9228bfd895ef79863a8e78a6b68e96b06774e703ac9075bd5"
13     sha256 cellar: :any_skip_relocation, arm64_ventura: "05ab3b695c06c0f9228bfd895ef79863a8e78a6b68e96b06774e703ac9075bd5"
14     sha256 cellar: :any_skip_relocation, sonoma:        "6320979297527ca632fa428271fa3519e3382e90c6d02a6bc1fd8c0886d23ae8"
15     sha256 cellar: :any_skip_relocation, ventura:       "6320979297527ca632fa428271fa3519e3382e90c6d02a6bc1fd8c0886d23ae8"
16     sha256 cellar: :any_skip_relocation, x86_64_linux:  "f7957fcca28005c5d81736033b68312872485b673a1e01ec53d1c7e98b11050b"
17   end
19   depends_on "go" => :build
21   conflicts_with "chisel", because: "both install `chisel` binaries"
23   def install
24     ldflags = "-s -w -X github.com/jpillora/chisel/share.BuildVersion=v#{version}"
25     system "go", "build", *std_go_args(ldflags:, output: bin/"chisel")
26   end
28   test do
29     _, write = IO.pipe
30     server_port = free_port
32     server_pid = fork do
33       exec "#{bin}/chisel server -p #{server_port}", out: write, err: write
34     end
36     sleep 2
38     begin
39       assert_match "Connected", shell_output("curl -v 127.0.0.1:#{server_port} 2>&1")
40     ensure
41       Process.kill("TERM", server_pid)
42       Process.wait(server_pid)
43     end
44   end
45 end