修复与更新:改变了DNS接收解析的方式,能够适应GoogleDNS、CloudFlareDNS请求时夹带DNSSEC的请求
This commit is contained in:
parent
2fab753800
commit
e8c16dd28c
62
test.php
62
test.php
@ -1,20 +1,48 @@
|
||||
<?php
|
||||
#print_r(dns_get_record('icu',DNS_SOA));
|
||||
$url='al.c919.n3n.com.cn';
|
||||
while(true){
|
||||
preg_match("#\.(.*)#i",$url,$match);//获取根域名
|
||||
$domin = $match[1];
|
||||
print_r($domin);
|
||||
$soa=dns_get_record($domin,DNS_SOA);
|
||||
if(array_key_exists('0',$soa)){
|
||||
if(array_key_exists('mname',$soa[0])){
|
||||
print_r($soa[0]);
|
||||
break;
|
||||
}else{
|
||||
$url=$domin;
|
||||
}
|
||||
}else{
|
||||
$url=$domin;
|
||||
$data='a7df00100001000000000001013103646e730457434c4d0264650000010001000029057800008000000b00080007000118007541b3';
|
||||
$id=substr($data,0,4);
|
||||
$flag=substr($data,4,4);
|
||||
$questions=substr($data,8,4);
|
||||
$answerRRs=substr($data,12,4);
|
||||
$authorityRRs=substr($data,16,4);
|
||||
$additionalRRs=substr($data,20,4);
|
||||
$startbyte=24;
|
||||
$dlen=substr($data,$startbyte,2);
|
||||
$startbyte=26;
|
||||
$i=1;
|
||||
while($dlen!='00'){
|
||||
$domain[$i]=hex2bin(substr($data,$startbyte,hexdec($dlen)*2));
|
||||
$startbyte=$startbyte+(hexdec($dlen)*2);
|
||||
$dlen=substr($data,$startbyte,2);
|
||||
$startbyte=$startbyte+2;
|
||||
$i++;
|
||||
}
|
||||
$name=join(".",$domain);
|
||||
$type=substr($data,$startbyte,4);
|
||||
switch($type){
|
||||
case '0001':
|
||||
$type='A';
|
||||
break;
|
||||
case '0002':
|
||||
$type='NS';
|
||||
break;
|
||||
case '000c':
|
||||
$type='PTR';
|
||||
break;
|
||||
case '0006':
|
||||
$type='SOA';
|
||||
break;
|
||||
case '001c':
|
||||
$type='AAAA';
|
||||
break;
|
||||
case '0005':
|
||||
$type='CNAME';
|
||||
break;
|
||||
case '0010':
|
||||
$type='TEXT';
|
||||
break;
|
||||
case '000f':
|
||||
$type='MX';
|
||||
break;
|
||||
}
|
||||
?>
|
||||
$query=substr($data,24,$startbyte-20);
|
43
vendor/workerman/workerman.log
vendored
43
vendor/workerman/workerman.log
vendored
@ -766,3 +766,46 @@ Stack trace:
|
||||
2022-12-18 10:00:06 pid:4770 Workerman[start.php] start in DEBUG mode
|
||||
2022-12-18 10:00:16 pid:4770 Workerman[start.php] stopping ...
|
||||
2022-12-18 10:00:16 pid:4770 Workerman[start.php] has been stopped
|
||||
2024-01-29 07:41:24 pid:1257 Workerman[start.php] start in DEBUG mode
|
||||
2024-01-29 07:49:27 pid:1257 Workerman[start.php] stopping ...
|
||||
2024-01-29 07:49:27 pid:1257 Workerman[start.php] has been stopped
|
||||
2024-01-29 07:49:28 pid:2216 Workerman[start.php] start in DEBUG mode
|
||||
2024-01-29 07:56:55 pid:2216 Workerman[start.php] stopping ...
|
||||
2024-01-29 07:56:55 pid:2216 Workerman[start.php] has been stopped
|
||||
2024-01-29 07:56:57 pid:3166 Workerman[start.php] start in DEBUG mode
|
||||
2024-01-29 07:57:24 pid:3166 Workerman[start.php] stopping ...
|
||||
2024-01-29 07:57:24 pid:3166 Workerman[start.php] has been stopped
|
||||
2024-01-29 07:57:24 pid:3279 Workerman[start.php] start in DEBUG mode
|
||||
2024-01-29 08:26:44 pid:3279 Workerman[start.php] stopping ...
|
||||
2024-01-29 08:26:44 pid:3279 Workerman[start.php] has been stopped
|
||||
2024-01-29 08:26:45 pid:6855 Workerman[start.php] start in DEBUG mode
|
||||
2024-01-29 08:27:10 pid:6855 Workerman[start.php] stopping ...
|
||||
2024-01-29 08:27:11 pid:6855 Workerman[start.php] stopping ...
|
||||
2024-01-29 08:27:11 pid:6855 Workerman[start.php] stopping ...
|
||||
2024-01-29 08:27:11 pid:6855 Workerman[start.php] stopping ...
|
||||
2024-01-29 08:27:12 pid:6855 Workerman[start.php] stopping ...
|
||||
2024-01-29 08:27:12 pid:6855 Workerman[start.php] stopping ...
|
||||
2024-01-29 08:27:12 pid:6855 worker[none:6857] exit with status 9
|
||||
2024-01-29 08:27:12 pid:6855 Workerman[start.php] has been stopped
|
||||
2024-01-29 08:27:30 pid:7036 Workerman[start.php] start in DEBUG mode
|
||||
2024-01-29 08:27:57 pid:7036 Workerman[start.php] stopping ...
|
||||
2024-01-29 08:27:57 pid:7036 Workerman[start.php] has been stopped
|
||||
2024-01-29 08:27:57 pid:7144 Workerman[start.php] start in DEBUG mode
|
||||
2024-01-29 08:28:17 pid:7144 Workerman[start.php] stopping ...
|
||||
2024-01-29 08:28:17 pid:7144 Workerman[start.php] has been stopped
|
||||
2024-01-29 08:28:18 pid:7222 Workerman[start.php] start in DEBUG mode
|
||||
2024-01-29 08:28:46 pid:7222 Workerman[start.php] stopping ...
|
||||
2024-01-29 08:28:46 pid:7222 Workerman[start.php] has been stopped
|
||||
2024-01-29 08:28:46 pid:7312 Workerman[start.php] start in DEBUG mode
|
||||
2024-01-29 08:29:09 pid:7312 Workerman[start.php] stopping ...
|
||||
2024-01-29 08:29:09 pid:7312 Workerman[start.php] has been stopped
|
||||
2024-01-29 08:29:09 pid:7388 Workerman[start.php] start in DEBUG mode
|
||||
2024-01-29 08:29:19 pid:7388 Workerman[start.php] stopping ...
|
||||
2024-01-29 08:29:19 pid:7388 Workerman[start.php] has been stopped
|
||||
2024-01-29 08:29:20 pid:7446 Workerman[start.php] start in DEBUG mode
|
||||
2024-01-29 08:29:34 pid:7446 Workerman[start.php] stopping ...
|
||||
2024-01-29 08:29:34 pid:7446 Workerman[start.php] has been stopped
|
||||
2024-01-29 08:29:34 pid:7515 Workerman[start.php] start in DEBUG mode
|
||||
2024-01-29 08:29:51 pid:7515 Workerman[start.php] stopping ...
|
||||
2024-01-29 08:29:51 pid:7515 Workerman[start.php] has been stopped
|
||||
2024-01-29 08:29:51 pid:7583 Workerman[start.php] start in DEBUG mode
|
||||
|
54
vendor/workerman/workerman/Protocols/Dns.php
vendored
54
vendor/workerman/workerman/Protocols/Dns.php
vendored
@ -369,8 +369,11 @@ class Dns
|
||||
*/
|
||||
public static function decode($buffer)
|
||||
{
|
||||
/**
|
||||
$data=bin2hex($buffer);
|
||||
echo $data;
|
||||
$id=substr($data,0,4);
|
||||
$flag=substr($data,5,4);
|
||||
$type=substr($data,-8,4);
|
||||
switch($type){
|
||||
case '0001':
|
||||
@ -410,8 +413,59 @@ class Dns
|
||||
}
|
||||
$realname=substr($realname,1,-1);
|
||||
$query=substr($data,24);
|
||||
***/
|
||||
|
||||
#$returndata="$type".'|||'."$realname";
|
||||
$data=bin2hex($buffer);
|
||||
$id=substr($data,0,4);
|
||||
$flag=substr($data,4,4);
|
||||
$questions=substr($data,8,4);
|
||||
$answerRRs=substr($data,12,4);
|
||||
$authorityRRs=substr($data,16,4);
|
||||
$additionalRRs=substr($data,20,4);
|
||||
$startbyte=24;
|
||||
$dlen=substr($data,$startbyte,2);
|
||||
$startbyte=26;
|
||||
$i=1;
|
||||
while($dlen!='00'){
|
||||
$domain[$i]=hex2bin(substr($data,$startbyte,hexdec($dlen)*2));
|
||||
$startbyte=$startbyte+(hexdec($dlen)*2);
|
||||
$dlen=substr($data,$startbyte,2);
|
||||
$startbyte=$startbyte+2;
|
||||
$i++;
|
||||
}
|
||||
$realname=join(".",$domain);
|
||||
$type=substr($data,$startbyte,4);
|
||||
switch($type){
|
||||
case '0001':
|
||||
$type='A';
|
||||
break;
|
||||
case '0002':
|
||||
$type='NS';
|
||||
break;
|
||||
case '000c':
|
||||
$type='PTR';
|
||||
break;
|
||||
case '0006':
|
||||
$type='SOA';
|
||||
break;
|
||||
case '001c':
|
||||
$type='AAAA';
|
||||
break;
|
||||
case '0005':
|
||||
$type='CNAME';
|
||||
break;
|
||||
case '0010':
|
||||
$type='TEXT';
|
||||
break;
|
||||
case '000f':
|
||||
$type='MX';
|
||||
break;
|
||||
}
|
||||
$query=substr($data,24,$startbyte-16);
|
||||
echo $query."\n";
|
||||
|
||||
|
||||
$returndata= json_encode(array('type' => $type, 'name' => "$realname", 'id'=>"$id", 'query'=>"$query"));
|
||||
|
||||
return $returndata;
|
||||
|
Loading…
Reference in New Issue
Block a user