Webman-Dns/src/resource/DnsProcess.php

28 lines
772 B
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace process;
use Workerman\Connection\TcpConnection;
use app\controller\DnsController;
class DnsProcess
{
public function onMessage($connection, $data)
{
$data=json_decode($data);
$type=$data->type; #查询类型
$name=$data->name; #查询内容(一般是域名PTR时为倒序IP)
$rip=$connection->getRemoteIp(); #客户端IP
if(isset($data->addR->csubnet->ip)){
$ip=$data->addR->csubnet->ip;
}else{
$ip=$rip;
}
#输出信息
#echo "\n Type:$type \n Domain: $name\n Client IP: $rip \n";
$dns=new DnsController;
$return=$dns->DNS($type,$name,$rip,$ip,$data->id,$data->query,$data->traffic);
$connection->send($return);
}
}