transport = 'udp'; $worker->onMessage = function($connection, $data){ $data=json_decode($data); $type=$data->type; $name=$data->name; $rip=$connection->getRemoteIp(); #输出信息 #echo "Type: $type \n Domain: $name\n Client IP: $rip \n"; /** A类记录返回 $send['type']='A'; $send['detail']='119.29.29.29'; $send['ttl']=30; **/ $send['type']='NS'; $send['detail'][1]='coco.bunny.net'; $send['detail'][2]='kiki.bunny.net'; $send['ttl']=30; #id和query一般情况下直接返回输出即可 $send['id']=$data->id; $send['query']=$data->query; $send=json_encode($send); $connection->send($send); }; Worker::runAll();