]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Fix use of IO::Socket::IP on windows 2025
authorNeil Horman <nhorman@openssl.org>
Fri, 6 Jun 2025 00:57:35 +0000 (20:57 -0400)
committerTomas Mraz <tomas@openssl.org>
Fri, 6 Jun 2025 07:39:02 +0000 (09:39 +0200)
Apparently IO::Socket::IP has several odd behaviors on windows 2025,
notably indicating that AF_INET6 isn't a supported family when it
clearly is.

Follow the pattern in determinig the haveIPV6 variable in Proxy.pm, and
record if we determine IPv6 availablity with the IP class or the INET6
class and use the same method when testing port binding

Fixes project/#1213

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Paul Yang <kaishen.yy@antfin.com>
(Merged from https://github.com/openssl/openssl/pull/27780)

(cherry picked from commit ae404a9b3bd052963b76434bcc97757d1d6d502e)

util/perl/TLSProxy/Proxy.pm

index 64da22bfb997a23cbc037bfbd8040e2aeebdc4be..59de9e934595b8c42e062d877bd481f446e46ff8 100644 (file)
@@ -26,6 +26,7 @@ use TLSProxy::NewSessionTicket;
 use TLSProxy::NextProto;
 
 my $have_IPv6;
+my $useINET6;
 my $IP_factory;
 
 BEGIN
@@ -48,6 +49,7 @@ BEGIN
     if ($@ eq "") {
         $IP_factory = sub { IO::Socket::INET6->new(Domain => AF_INET6, @_); };
         $have_IPv6 = 1;
+        $useINET6 = 1;
     } else {
         eval {
             require IO::Socket::IP;
@@ -62,9 +64,11 @@ BEGIN
         if ($@ eq "") {
             $IP_factory = sub { IO::Socket::IP->new(@_); };
             $have_IPv6 = 1;
+            $useINET6 = 0;
         } else {
             $IP_factory = sub { IO::Socket::INET->new(@_); };
             $have_IPv6 = 0;
+            $useINET6 = 0;
         }
     }
 }
@@ -93,14 +97,13 @@ sub new
     for (my $i = 0; $i <= 10; $i++) {
         $test_client_port = 49152 + int(rand(65535 - 49152));
         my $test_sock;
-        if ($have_IPv6) {
-            $test_sock = IO::Socket::IP->new(Family => AF_INET6,
-                                             LocalPort => $test_client_port,
+        if ($useINET6 == 0) {
+            $test_sock = IO::Socket::IP->new(LocalPort => $test_client_port,
                                              LocalAddr => $test_client_addr);
         } else {
-            $test_sock = IO::Socket::IP->new(Family => AF_INET,
-                                             LocalPort => $test_client_port,
-                                             LocalAddr => $test_client_addr);
+            $test_sock = IO::Socket::INET6->new(LocalAddr => $test_client_addr,
+                                                LocalPort => $test_client_port,
+                                                Domain => AF_INET6);
         }
         if ($test_sock) {
             $found_port = 1;
@@ -108,7 +111,7 @@ sub new
             print "Found available client port ${test_client_port}\n";
             last;
         }
-        print "Port ${test_client_port} in use.  Trying again\n";
+        print "Port ${test_client_port} in use - $@\n";
     }
   
     if ($found_port == 0) {