fix bugs
This commit is contained in:
parent
fff40982a3
commit
bfa4742524
@ -19,10 +19,24 @@ class DnsController
|
|||||||
#此处请根据业务需要,通过判断$name和$rip返回正确的数据
|
#此处请根据业务需要,通过判断$name和$rip返回正确的数据
|
||||||
#详情请参见 https://github.com/ywnsya/workerman-dns 尤其是 https://github.com/ywnsya/Workerman-DNS/blob/master/start.php 中的用法
|
#详情请参见 https://github.com/ywnsya/workerman-dns 尤其是 https://github.com/ywnsya/Workerman-DNS/blob/master/start.php 中的用法
|
||||||
|
|
||||||
|
if($type=='PTR'){
|
||||||
$send['detail']='dns.laysense.com';
|
$send['detail']='dns.laysense.com';
|
||||||
$send['ttl']=30;
|
$send['ttl']=30;
|
||||||
$send['type']='PTR';
|
$send['type']='PTR';
|
||||||
|
}
|
||||||
|
if($type=='A'){
|
||||||
|
$send['type']='A';
|
||||||
|
$send['detail'][1]='119.29.29.29';
|
||||||
|
$send['detail'][2]='8.8.8.8';
|
||||||
|
$send['ttl']=30;
|
||||||
|
};
|
||||||
|
if($type=='AAAA'){
|
||||||
|
$ipv6=new IPv6;
|
||||||
|
$send['type']='AAAA';
|
||||||
|
$send['detail'][1]=bin2hex($ipv6->ip2bin("fe80::2c5f")); #此操作可以还原被简化的IPv6地址 协议内不再对IPv6地址进行处理,请按照本方式传递16进制无":"的完整16位IPv6
|
||||||
|
$send['detail'][2]=bin2hex($ipv6->ip2bin("2001:0:2851:b9d0:2c5f:f0d9:21be:4b96"));
|
||||||
|
$send['ttl']=600;
|
||||||
|
}
|
||||||
|
|
||||||
#此处无需修改
|
#此处无需修改
|
||||||
$send['id']=$id;
|
$send['id']=$id;
|
||||||
|
@ -1,27 +1,24 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace process;
|
namespace process;
|
||||||
|
|
||||||
use Workerman\Connection\TcpConnection;
|
use Workerman\Connection\TcpConnection;
|
||||||
|
use app\controller\DnsController;
|
||||||
|
|
||||||
class DnsProcess
|
class DnsProcess
|
||||||
{
|
{
|
||||||
public function onConnect(TcpConnection $connection)
|
|
||||||
|
public function onMessage($connection, $data)
|
||||||
{
|
{
|
||||||
echo "onConnect\n";
|
$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->DNS($type,$name,$rip,$data->id,$data->query);
|
||||||
|
$connection->send($return);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onWebSocketConnect(TcpConnection $connection, $http_buffer)
|
|
||||||
{
|
|
||||||
echo "onWebSocketConnect\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
public function onMessage(TcpConnection $connection, $data)
|
|
||||||
{
|
|
||||||
$connection->send($data);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function onClose(TcpConnection $connection)
|
|
||||||
{
|
|
||||||
echo "onClose\n";
|
|
||||||
}
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user