Please answer these questions before submitting your issue. Thanks!
go(function(){
......省略部分代码......
for ($i = 0; $i <= 5; $i++) {
$ip = swoole_async_dns_lookup_coro($response->uri->getHost());
if (! in_array($ip, $dnsIps)) {
array_push($dnsIps, $ip);
}
}
......省略部分代码......
});
{
"dnsLookup": [
"106.75.164.19",
"106.75.164.1916"
]
}
What did you expect to see?
期望得到正常IP地址
What did you see instead?
不正常IP地址:106.75.164.1916
What version of Swoole are you using (show your php --ri swoole)?
# php --ri swoole
swoole
swoole support => enabled
Version => 4.2.9
Author => Swoole Group[email: [email protected]]
coroutine => enabled
debug => enabled
trace_log => enabled
epoll => enabled
eventfd => enabled
signalfd => enabled
cpu_affinity => enabled
spinlock => enabled
rwlock => enabled
sockets => enabled
openssl => OpenSSL 1.0.2k-fips 26 Jan 2017
http2 => 1.31.1
pcre => enabled
zlib => enabled
mutex_timedlock => enabled
pthread_barrier => enabled
futex => enabled
mysqlnd => enabled
async_redis => enabled
Directive => Local Value => Master Value
swoole.enable_coroutine => On => On
swoole.aio_thread_num => 2 => 2
swoole.display_errors => On => On
swoole.use_namespace => On => On
swoole.use_shortname => On => On
swoole.fast_serialize => Off => Off
swoole.unixsock_buffer_size => 8388608 => 8388608
# uname -a
Linux izwz99ilp8qh025s8ak1y9z 3.10.0-693.2.2.el7.x86_64 #1 SMP Tue Sep 12 22:26:13 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
# php -v
PHP 7.1.24 (cli) (built: Nov 7 2018 18:08:20) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.1.24, Copyright (c) 1999-2018, by Zend Technologies
# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.8.5 20150623 (Red Hat 4.8.5-28) (GCC)
你得给出URI 不然我们没法验证 以及是否自己使用了代理DNS等
@twose
{
"uri": "www.bilibili.com",
"dnsLookup": [
"106.75.152.221",
"106.75.152.2216"
]
}
没有使用代理DNS,就是在一个外网服务器上跑的代码
curl -H 'Host: www.bilibili.com' -i http://你查到的IP
如
curl -H 'Host: www.bilibili.com' -i 106.75.152.221
HTTP/1.1 301 Moved Permanently
Server: Tengine
Date: Thu, 06 Dec 2018 10:48:30 GMT
Content-Type: text/html
Content-Length: 278
Connection: keep-alive
Location: https://www.bilibili.com/
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html>
<head><title>301 Moved Permanently</title></head>
<body bgcolor="white">
<h1>301 Moved Permanently</h1>
<p>The requested resource has been assigned a new permanent URI.</p>
<hr/>Powered by Tengine</body>
</html>
的确是bilibili
最好用co::getHostByName
@twose 但是为啥第二个ip最后一个数字是四位?106.75.152.2216
@twose 改成 co::getHostByName 正常了
```json
{
"uri": "www.bilibili.com",
"dnsLookup": [
"110.43.34.72",
"106.75.152.221",
"106.75.162.231",
"139.159.241.37"
]
}
swoole_async_dns_lookup_coro可能存在BUG