swoole-src icon indicating copy to clipboard operation
swoole-src copied to clipboard

With the Socks5 proxy enabled, the Coroutine HTTP client uses IPv6 addresses as domain names for DNS resolution

Open Alion548 opened this issue 3 years ago • 1 comments

Please answer these questions before submitting your issue. Thanks!

  1. What did you do? If possible, provide a simple script for reproducing the error.
use Swoole\Coroutine\Http\Client;
use function Swoole\Coroutine\run;

run(function () {
    $client = new Client('2600:1417:7800:8ad::180c', 443, true);
    $client->setHeaders([
        'Host' => 'www.qq.com'
    ]);

    $client->set([
        'ssl_host_name' => 'www.qq.com',
        'socks5_host' => '127.0.0.1',
        'socks5_port' => 1067
    ]);

    $client->get('/');
    echo $client->errMsg;
    echo $client->body;
    $client->close();
});
  1. What did you expect to see?
DNS Lookup resolve failed.
  1. What did you see instead? Proper handling of IPv6 addresses.

  2. What version of Swoole are you using (show your php --ri swoole)?

php --ri swoole

swoole

Swoole => enabled
Author => Swoole Team <[email protected]>
Version => 4.7.0-dev
Built => Jul  4 2021 03:11:21
coroutine => enabled with boost asm context
epoll => enabled
eventfd => enabled
signalfd => enabled
cpu_affinity => enabled
spinlock => enabled
rwlock => enabled
openssl => OpenSSL 1.1.1k  FIPS 25 Mar 2021
dtls => enabled
http2 => enabled
zlib => 1.2.11
mutex_timedlock => enabled
pthread_barrier => enabled
futex => enabled
async_redis => enabled

Directive => Local Value => Master Value
swoole.enable_coroutine => On => On
swoole.enable_library => On => On
swoole.enable_preemptive_scheduler => Off => Off
swoole.display_errors => On => On
swoole.use_shortname => On => On
swoole.unixsock_buffer_size => 8388608 => 8388608

Alion548 avatar Jul 08 '21 07:07 Alion548

Changing socks5_host to [::] will fix,But set to [::] does not support IPv4 URLs.

Alion548 avatar Jul 08 '21 08:07 Alion548