Skip to content

Commit 124353a

Browse files
committed
hack/test-port-forwarding.pl: Use -G for connection timeout to nc on macOS
Signed-off-by: Norio Nomura <[email protected]>
1 parent 6eb6232 commit 124353a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

hack/test-port-forwarding.pl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,12 @@
201201
next if $test->{host_port} == $sshLocalPort;
202202
my $cmd;
203203
if ($writer eq "nc") {
204-
$cmd = $test->{host_socket} eq "" ? "nc -w $connectionTimeout $test->{host_ip} $test->{host_port}" : "nc -w $connectionTimeout -U $test->{host_socket}";
204+
if ($Config{osname} eq "darwin") {
205+
# macOS nc doesn't support -w for connection timeout, so use -G instead
206+
$cmd = $test->{host_socket} eq "" ? "nc -G $connectionTimeout $test->{host_ip} $test->{host_port}" : "nc -G $connectionTimeout -U $test->{host_socket}";
207+
} else {
208+
$cmd = $test->{host_socket} eq "" ? "nc -w $connectionTimeout $test->{host_ip} $test->{host_port}" : "nc -w $connectionTimeout -U $test->{host_socket}";
209+
}
205210
} elsif ($writer eq "socat") {
206211
my $tcp_dest = $test->{host_ip} =~ /:/ ? "TCP6:[$test->{host_ip}]:$test->{host_port}" : "TCP:$test->{host_ip}:$test->{host_port}";
207212
$cmd = $test->{host_socket} eq "" ? "socat -u STDIN $tcp_dest,connect-timeout=$connectionTimeout" : "socat -u STDIN UNIX-CONNECT:$test->{host_socket}";

0 commit comments

Comments
 (0)