35 lines
848 B
PHP
35 lines
848 B
PHP
<?php
|
||
namespace process;
|
||
use Workerman\Connection\TcpConnection;
|
||
include_once(base_path().'/app/controller/DnsController.php');
|
||
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
|
||
|
||
#输出信息
|
||
echo "\n Type:$type \n Domain: $name\n Client IP: $rip \n";
|
||
|
||
$dns=new DnsController;
|
||
$return=$dns->$type($name,$rip);
|
||
/**
|
||
$send['type']='PTR';
|
||
$send['detail']='dns.laysense.com';
|
||
$send['ttl']=30;
|
||
|
||
$send['id']=$data->id;
|
||
$send['query']=$data->query;
|
||
|
||
|
||
*/
|
||
$connection->send($return);
|
||
}
|
||
|
||
} |