client = $client; $this->headers = $headers; $profileName = mt_rand(1, 9) . mt_rand(1, 9) . mt_rand(1, 9) . '#dns-' . $this->client->urlData['host']; $this->requestId = $this->getContext()->getLogId(); getInstance()->scheduler->IOCallBack[$this->requestId][] = $this; $this->getContext()->getLog()->profileStart($profileName); $keys = array_keys(getInstance()->scheduler->IOCallBack[$this->requestId]); $this->ioBackKey = array_pop($keys); $this->send(function (Client $client) use ($profileName) { if ($this->isBreak) { return; } if (empty(getInstance()->scheduler->taskMap[$this->requestId])) { return; } $this->result = $client; $this->responseTime = microtime(true); $this->getContext()->getLog()->profileEnd($profileName); $this->ioBack = true; $this->nextRun(); }); } /** * 发送DNS查询请求 * * @param callable $callback DNS解析完成后的回调 * @return $this */ public function send($callback) { $this->client->asyncDNSLookup($callback, $this->headers); return $this; } /** * 销毁 */ public function destroy() { parent::destroy(); } }