From: Neil Horman Date: Tue, 1 Jul 2025 18:19:17 +0000 (-0400) Subject: Fixup non-optional use of IO::Socket::IP X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c6ba456e120fe7b7ecb26fffd65729b9e7463b85;p=thirdparty%2Fopenssl.git Fixup non-optional use of IO::Socket::IP IO::Socket::IP is an optionally used package in our perl scripts, and a recent change of mine used it unilaterally, causing breakage on older perl installations. Fix it up to use it optionally again, falling back to IO::Socket::INET when needed. Fixes #27940 Reviewed-by: Richard Levitte Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/27941) (cherry picked from commit b321bf25c88f2e604f3dd387dd14e1e6369895ad) --- diff --git a/util/perl/TLSProxy/Proxy.pm b/util/perl/TLSProxy/Proxy.pm index 7cefdd3698d..fc17199906e 100644 --- a/util/perl/TLSProxy/Proxy.pm +++ b/util/perl/TLSProxy/Proxy.pm @@ -97,7 +97,23 @@ sub new_dtls { sub init { - require IO::Socket::IP; + my $useSockInet = 0; + eval { + require IO::Socket::IP; + my $s = IO::Socket::IP->new( + LocalAddr => "::1", + LocalPort => 0, + Listen=>1, + ); + $s or die "\n"; + $s->close(); + }; + if ($@ eq "") { + require IO::Socket::IP; + } else { + $useSockInet = 1; + } + my $class = shift; my ($filter, $execute, @@ -118,8 +134,13 @@ sub init $test_client_port = 49152 + int(rand(65535 - 49152)); my $test_sock; if ($useINET6 == 0) { - $test_sock = IO::Socket::IP->new(LocalPort => $test_client_port, - LocalAddr => $test_client_addr); + if ($useSockInet == 0) { + $test_sock = IO::Socket::IP->new(LocalPort => $test_client_port, + LocalAddr => $test_client_addr); + } else { + $test_sock = IO::Socket::INET->new(LocalAddr => $test_client_addr, + LocalPort => $test_client_port); + } } else { $test_sock = IO::Socket::INET6->new(LocalAddr => $test_client_addr, LocalPort => $test_client_port,