Skip to content

Commit b683b0f

Browse files
authored
Merge pull request Homebrew#253615 from Sesame2/gotun
gotun 0.6.1 (new formula)
2 parents 300ea10 + 4f41dd6 commit b683b0f

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

Formula/g/gotun.rb

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
class Gotun < Formula
2+
desc "Lightweight HTTP proxy over SSH"
3+
homepage "https://github.com/Sesame2/gotun"
4+
url "https://github.com/Sesame2/gotun/archive/refs/tags/v0.6.1.tar.gz"
5+
sha256 "d63768ad7ae61b2fa29f100e22af19b9d43886eb85712e64c58d24b9408b92c1"
6+
license "MIT"
7+
8+
bottle do
9+
sha256 cellar: :any_skip_relocation, arm64_tahoe: "700956caa0621363c75435dcb00f638b26ac709be5b41cc850561b05c99bc94b"
10+
sha256 cellar: :any_skip_relocation, arm64_sequoia: "700956caa0621363c75435dcb00f638b26ac709be5b41cc850561b05c99bc94b"
11+
sha256 cellar: :any_skip_relocation, arm64_sonoma: "700956caa0621363c75435dcb00f638b26ac709be5b41cc850561b05c99bc94b"
12+
sha256 cellar: :any_skip_relocation, sonoma: "9359d4ea158a6c165a1f02c694cde47e5155234933c2136500fb5433027b562b"
13+
sha256 cellar: :any_skip_relocation, arm64_linux: "d25f8a2fc8013990e210a4654bd55d91fb53135133a300c6f778235434ed6037"
14+
sha256 cellar: :any_skip_relocation, x86_64_linux: "f89af90bec14e9b584e6e2fb1751f11809f72ad43d570c6ef56ff69c79b52d94"
15+
end
16+
17+
depends_on "go" => :build
18+
19+
def install
20+
ldflags = "-s -w -X main.Version=#{version}"
21+
system "go", "build", *std_go_args(ldflags:), "./cmd/gotun"
22+
generate_completions_from_executable(bin/"gotun", "completion")
23+
end
24+
25+
test do
26+
assert_match version.to_s, shell_output("#{bin}/gotun --version")
27+
28+
port = free_port
29+
server = TCPServer.new(port)
30+
server_pid = fork do
31+
msg = server.accept.gets
32+
server.close
33+
assert_match "SSH", msg
34+
end
35+
36+
require "pty"
37+
r, _, pid = PTY.spawn bin/"gotun", "anonymous@localhost", "-p", port.to_s, "--timeout", "1s"
38+
sleep 1
39+
Process.kill "TERM", pid
40+
41+
output = ""
42+
begin
43+
r.each_line { |line| output += line }
44+
rescue Errno::EIO
45+
# GNU/Linux raises EIO when read is done on closed pty
46+
end
47+
48+
assert_match "HTTP-over-SSH", output
49+
assert_match "localhost:#{port}", output
50+
ensure
51+
Process.kill "TERM", server_pid
52+
Process.wait server_pid
53+
Process.wait pid
54+
end
55+
end

0 commit comments

Comments
 (0)