Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ehco 1.1.1 #92001

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 17 additions & 10 deletions Formula/ehco.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
class Ehco < Formula
desc "Network relay tool and a typo :)"
homepage "https://github.com/Ehco1996/ehco"
url "https://github.com/Ehco1996/ehco/archive/refs/tags/v1.0.7.tar.gz"
sha256 "d6384cdb31befcf9a198dd1be6c0073e9fabb6823f2f92df63bb50fb14ec6ff1"
url "https://github.com/Ehco1996/ehco.git",
tag: "v1.1.1",
revision: "c723fa0c3fefcc7f89c3847c6cd753cfdaf30486"
license "GPL-3.0-only"

livecheck do
Expand All @@ -21,27 +22,33 @@ class Ehco < Formula

depends_on "go" => :build

uses_from_macos "netcat" => :test

def install
system "go", "build", *std_go_args, "cmd/ehco/main.go"
ldflags = %W[
-s -w
-X github.com/Ehco1996/ehco/internal/constant.GitBranch=master
SMillerDev marked this conversation as resolved.
Show resolved Hide resolved
-X github.com/Ehco1996/ehco/internal/constant.GitRevision=#{Utils.git_short_head}
-X github.com/Ehco1996/ehco/internal/constant.BuildTime=#{time.iso8601}
]

system "go", "build", *std_go_args(ldflags: ldflags), "cmd/ehco/main.go"
end

test do
version_info = shell_output("#{bin}/ehco -v")
assert_match "ehco version #{version}", version_info
version_info = shell_output("#{bin}/ehco -v 2>&1")
assert_match "Version=#{version}", version_info

# run nc server
nc_port = free_port
nc_pid = spawn "nc", "-l", nc_port.to_s
spawn "nc", "-l", nc_port.to_s
sleep 1

# run ehco server
listen_port = free_port
ehco_pid = spawn bin/"ehco", "-l", "localhost:#{listen_port}", "-r", "localhost:#{nc_port}"
spawn bin/"ehco", "-l", "localhost:#{listen_port}", "-r", "localhost:#{nc_port}"
sleep 1

system "nc", "-z", "localhost", listen_port.to_s
ensure
Process.kill("HUP", ehco_pid)
Process.kill("HUP", nc_pid)
end
end