[wp-trac] [WordPress Trac] #21446: plugins using curl with IPV6 enabled servers

WordPress Trac noreply at wordpress.org
Thu Nov 3 03:26:03 UTC 2016


#21446: plugins using curl with IPV6 enabled servers
-------------------------+-----------------------
 Reporter:  mippie32     |       Owner:
     Type:  enhancement  |      Status:  reopened
 Priority:  normal       |   Milestone:
Component:  HTTP API     |     Version:  3.4.1
 Severity:  normal       |  Resolution:
 Keywords:  close        |     Focuses:
-------------------------+-----------------------
Changes (by svovaf):

 * status:  closed => reopened
 * resolution:  worksforme =>


Comment:

 I'm not sure if I should open a new ticket or put it here. We are
 rewriting [Freemius](https://freemius.com) cURL based SDK to work directly
 with `wp_remote` to support websites without cURL. While rewriting the SDK
 I stumbled in a use-case that seems to be not covered by the
 `Requests_Transport_cURL`. With dual stacked DNS responses, it's possible
 for a server to have IPv6 enabled but not have IPv6 connectivity.  If this
 is the case, cURL will try IPv4 first and if that fails, then it will fall
 back to IPv6 and the error EHOSTUNREACH will be returned by the operating
 system.

 Here's a code we've been using to tackle it on  (I think it was originally
 inspired by the login in the Facebook SDK):
 {{{#!php
 <?php
 // With dual stacked DNS responses, it's possible for a server to
 // have IPv6 enabled but not have IPv6 connectivity.  If this is
 // the case, curl will try IPv4 first and if that fails, then it will
 // fall back to IPv6 and the error EHOSTUNREACH is returned by the
 // operating system.
 if ( false === $result && empty( $opts[ CURLOPT_IPRESOLVE ] ) ) {
         $matches = array();
         $regex   = '/Failed to connect to ([^:].*): Network is
 unreachable/';
         if ( preg_match( $regex, curl_error( $pCurlHandler ), $matches ) )
 {
                 if ( strlen( @inet_pton( $matches[1] ) ) === 16 ) {
 //                        errorLog('Invalid IPv6 configuration on server,
 Please disable or get native IPv6 on your server.');
                         curl_setopt( $pCurlHandler, CURLOPT_IPRESOLVE,
 CURL_IPRESOLVE_V4 );
                 }
         }
 }
 }}}

 Any idea of how can we tackle it?

 Another issue worth mentioning is that cURL < v.7.37 doesn't support
 SSLv3, so all HTTPS requests to servers with the new protocol will
 basically fail. I didn't see any code related to that in the
 `Requests_Transport_cURL`.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/21446#comment:8>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list