From 91cce4c3d29ed494cd17324f1a53517c390daebc Mon Sep 17 00:00:00 2001 From: david Date: Fri, 16 Aug 2013 08:03:16 +0000 Subject: [PATCH] Connect to ::1 when -6 appears in the options. --- ncat/test/ncat-test.pl | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/ncat/test/ncat-test.pl b/ncat/test/ncat-test.pl index 834023bce..b984c80f9 100755 --- a/ncat/test/ncat-test.pl +++ b/ncat/test/ncat-test.pl @@ -79,8 +79,17 @@ sub ncat_server { return @ret; } +sub host_for_args { + if (grep(/^-[^-]*6/, @_)) { + return "::1"; + } else { + return "127.0.0.1"; + } +} + sub ncat_client { - my @ret = ncat($HOST, $PORT, @_); + my $host; + my @ret = ncat(host_for_args(@_), $PORT, @_); # Give it a moment to connect. select(undef, undef, undef, 0.1); return @ret; @@ -229,9 +238,9 @@ sub proxy_test { my $server_args = shift; my $client_args = shift; my $code = shift; - ($p_pid, $p_out, $p_in) = ncat(($HOST, $PROXY_PORT, "-l", "--proxy-type", "http"), @$proxy_args); - ($s_pid, $s_out, $s_in) = ncat(($HOST, $PORT, "-l"), @$server_args); - ($c_pid, $c_out, $c_in) = ncat(($HOST, $PORT, "--proxy", "$HOST:$PROXY_PORT"), @$client_args); + ($p_pid, $p_out, $p_in) = ncat(host_for_args(@$proxy_args), ($PROXY_PORT, "-l", "--proxy-type", "http"), @$proxy_args); + ($s_pid, $s_out, $s_in) = ncat(host_for_args(@$server_args), ($PORT, "-l"), @$server_args); + ($c_pid, $c_out, $c_in) = ncat(host_for_args(@$client_args), ($PORT, "--proxy", "$HOST:$PROXY_PORT"), @$client_args); test($desc, $code); kill_children; } @@ -244,9 +253,9 @@ sub proxy_test_raw { my $server_args = shift; my $client_args = shift; my $code = shift; - ($p_pid, $p_out, $p_in) = ncat(($HOST, $PROXY_PORT, "-l", "--proxy-type", "http"), @$proxy_args); - ($s_pid, $s_out, $s_in) = ncat(($HOST, $PORT, "-l"), @$server_args); - ($c_pid, $c_out, $c_in) = ncat(($HOST, $PROXY_PORT), @$client_args); + ($p_pid, $p_out, $p_in) = ncat(host_for_args(@$proxy_args), ($PROXY_PORT, "-l", "--proxy-type", "http"), @$proxy_args); + ($s_pid, $s_out, $s_in) = ncat(host_for_args(@$server_args), ($PORT, "-l"), @$server_args); + ($c_pid, $c_out, $c_in) = ncat(host_for_args(@$client_args), ($PROXY_PORT), @$client_args); test($desc, $code); kill_children; }