aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorSergio Oliveira2015-03-03 11:45:08 -0300
committerMike McQuaid2015-03-04 15:25:18 +0000
commit7bcb3d8ff2742306888af546acd790451f9fc44d (patch)
tree91f1ec54eda2e8a915ff4053165a8fce0a0e1f60 /Library
parent2f3de099c5ac21bd4f2fb9cedd7a94213daf8191 (diff)
downloadhomebrew-7bcb3d8ff2742306888af546acd790451f9fc44d.tar.bz2
redir 2.2.1_9 (new formula)
Redir is a port redirector. It's functionally basically consists of the ability to listen for TCP connections on a given port, and, when it receives a connection, to then connect to a given destination address/port, and pass data between them. It finds most of its applications in traversing firewalls, but, of course, there are other uses. Closes #37360. Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
Diffstat (limited to 'Library')
-rw-r--r--Library/Formula/redir.rb38
1 files changed, 38 insertions, 0 deletions
diff --git a/Library/Formula/redir.rb b/Library/Formula/redir.rb
new file mode 100644
index 000000000..82b08e944
--- /dev/null
+++ b/Library/Formula/redir.rb
@@ -0,0 +1,38 @@
+class Redir < Formula
+ homepage "http://sammy.net/~sammy/hacks/"
+ url "https://github.com/TracyWebTech/redir/archive/2.2.1-9.tar.gz"
+ version "2.2.1_9"
+ sha1 "84ae75104d79432bbc15f67e4dc2980e0912b2b6"
+
+ def install
+ system "make"
+ bin.install "redir"
+ man1.install "redir.man"
+ end
+
+ test do
+ redir_pid = fork do
+ exec "#{bin}/redir", "--cport=12345", "--lport=54321"
+ end
+ Process.detach(redir_pid)
+
+ nc_pid = fork do
+ exec "nc -l 12345"
+ end
+
+ # Give time to processes start
+ sleep(1)
+
+ begin
+ # Check if the process is running
+ system "kill", "-0", redir_pid
+
+ # Check if the port redirect works
+ system "nc", "-z", "localhost", "54321"
+ ensure
+ Process.kill("TERM", redir_pid)
+ Process.kill("TERM", nc_pid)
+ Process.wait(nc_pid)
+ end
+ end
+end