swoole / swoole-src

🚀 Coroutine-based concurrency library for PHP
https://www.swoole.com
Apache License 2.0
18.44k stars 3.16k forks source link

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

Open Alion548 opened 3 years ago

Alion548 commented 3 years ago

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();

});


2. What did you expect to see?
``` bash
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 team@swoole.com 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 commented 3 years ago

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