150 lines
4.4 KiB
PHP
150 lines
4.4 KiB
PHP
<?php
|
||
|
||
namespace app\controller;
|
||
include_once base_path().'/vendor/laysense/dns/src/resource/ipv6.php';
|
||
use dnstools\ipv6;
|
||
|
||
class DnsController
|
||
{
|
||
public function PTR($type,$name,$rip,$id,$query)
|
||
{
|
||
#输出信息
|
||
#echo "\n Type:$type \n Domain: $name\n Client IP: $rip \n";
|
||
|
||
#此处请根据业务需要,通过判断$name和$rip返回正确的数据
|
||
|
||
$send['detail']='dns.laysense.com';
|
||
$send['ttl']=30;
|
||
|
||
#以下无需更改
|
||
$send['type']='PTR';
|
||
$send['id']=$id;
|
||
$send['query']=$query;
|
||
$return=json_encode($send);
|
||
return $return;
|
||
}
|
||
|
||
#后续以此类推,function名为DNS查询类型
|
||
|
||
public function A($type,$name,$rip,$id,$query)
|
||
{
|
||
|
||
$send['detail'][1]='119.29.29.29';
|
||
$send['detail'][2]='8.8.8.8';
|
||
$send['ttl']=30;
|
||
|
||
$send['type']='A';
|
||
$send['id']=$id;
|
||
$send['query']=$query;
|
||
$return=json_encode($send);
|
||
return $return;
|
||
}
|
||
|
||
public function AAAA($type,$name,$rip,$id,$query)
|
||
{
|
||
$ipv6=new IPv6;
|
||
$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']=30;
|
||
|
||
|
||
$send['type']='AAAA';
|
||
$send['id']=$id;
|
||
$send['query']=$query;
|
||
$return=json_encode($send);
|
||
return $return;
|
||
}
|
||
|
||
public function NS($type,$name,$rip,$id,$query)
|
||
{
|
||
|
||
$send['detail'][1]='coco.bunny.net';
|
||
$send['detail'][2]='kiki.bunny.net';
|
||
$send['ttl']=600;
|
||
|
||
$send['type']='NS';
|
||
$send['id']=$id;
|
||
$send['query']=$query;
|
||
$return=json_encode($send);
|
||
return $return;
|
||
}
|
||
|
||
public function CNAME($type,$name,$rip,$id,$query)
|
||
{
|
||
|
||
$send['type']='CNAME';
|
||
$send['detail'][1]='baidu.cn';
|
||
$send['detail'][2]='baidu.com';
|
||
$send['ttl']=600;
|
||
|
||
$send['type']='CNAME';
|
||
$send['id']=$id;
|
||
$send['query']=$query;
|
||
$return=json_encode($send);
|
||
return $return;
|
||
}
|
||
|
||
public function TEXT($type,$name,$rip,$id,$query)
|
||
{
|
||
|
||
$send['detail'][1]='text1-test';
|
||
$send['detail'][2]='text2-test';
|
||
$send['ttl']=600;
|
||
|
||
$send['type']='TEXT';
|
||
$send['id']=$id;
|
||
$send['query']=$query;
|
||
$return=json_encode($send);
|
||
return $return;
|
||
}
|
||
|
||
public function MX($type,$name,$rip,$id,$query)
|
||
{
|
||
|
||
$send['detail'][1]['name']='mx.zoho.com';
|
||
$send['detail'][1]['pre']='20'; #权重
|
||
$send['detail'][2]['name']='mx2.zoho.com';
|
||
$send['detail'][2]['pre']='30'; #权重
|
||
$send['detail'][3]['name']='mx3.zoho.com';
|
||
$send['detail'][3]['pre']='50'; #权重
|
||
$send['ttl']=600;
|
||
|
||
$send['type']='MX';
|
||
$send['id']=$id;
|
||
$send['query']=$query;
|
||
$return=json_encode($send);
|
||
return $return;
|
||
}
|
||
|
||
public function SOA($type,$name,$rip,$id,$query)
|
||
{
|
||
$send['detail']= array();
|
||
|
||
$send['detail']['type']='none';
|
||
$send['detail']['name']=$name;
|
||
|
||
/**
|
||
* SOA类型,如遇域名存在但无该查询类型的记录时返回
|
||
* 请勿随意填写,本DNS协议将自动向服务器配置的DNS获取SOA
|
||
*
|
||
* 自行返回SOA记录(不建议)[除非你真的准备直接把域名NS到这里]
|
||
* $send['detail']['type']='self';
|
||
* $send['detail']['mname']='dns31.hichina.com'; #主DNS服务器名
|
||
* $send['detail']['rname']='hostmaster.hichina.com'; #DNS管理员邮箱
|
||
* $send['detail']['serial']='2022052002'; #序列号 序列号必须递增 类似于dns记录的版本号 序列号变大时递归dns将更新记录
|
||
* $send['detail']['refresh']='3600'; #区域应当被刷新前的时间间隔
|
||
* $send['detail']['retry']='1200'; #刷新失败重试的时间间隔
|
||
* $send['detail']['expire']='86400'; #规定在区域不再是权威的之前可以等待的时间间隔的上限
|
||
* $send['detail']['minimum-ttl']='600'; #最小TTL
|
||
*
|
||
* $send['ttl']='180'; #当前TTL
|
||
**/
|
||
|
||
|
||
$send['type']='SOA';
|
||
$send['id']=$id;
|
||
$send['query']=$query;
|
||
$return=json_encode($send);
|
||
return $return;
|
||
}
|
||
} |