From e8c16dd28cdff37335d207225b40a136047e30d9 Mon Sep 17 00:00:00 2001 From: Enoch Date: Mon, 29 Jan 2024 16:32:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=8E=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=EF=BC=9A=E6=94=B9=E5=8F=98=E4=BA=86DNS=E6=8E=A5=E6=94=B6?= =?UTF-8?q?=E8=A7=A3=E6=9E=90=E7=9A=84=E6=96=B9=E5=BC=8F=EF=BC=8C=E8=83=BD?= =?UTF-8?q?=E5=A4=9F=E9=80=82=E5=BA=94GoogleDNS=E3=80=81CloudFlareDNS?= =?UTF-8?q?=E8=AF=B7=E6=B1=82=E6=97=B6=E5=A4=B9=E5=B8=A6DNSSEC=E7=9A=84?= =?UTF-8?q?=E8=AF=B7=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test.php | 62 ++++++++++++++------ vendor/workerman/workerman.log | 43 ++++++++++++++ vendor/workerman/workerman/Protocols/Dns.php | 54 +++++++++++++++++ 3 files changed, 142 insertions(+), 17 deletions(-) diff --git a/test.php b/test.php index bf40a25..ab61913 100644 --- a/test.php +++ b/test.php @@ -1,20 +1,48 @@ +$query=substr($data,24,$startbyte-20); \ No newline at end of file diff --git a/vendor/workerman/workerman.log b/vendor/workerman/workerman.log index 52e74ea..475ce08 100644 --- a/vendor/workerman/workerman.log +++ b/vendor/workerman/workerman.log @@ -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 diff --git a/vendor/workerman/workerman/Protocols/Dns.php b/vendor/workerman/workerman/Protocols/Dns.php index f44ee5d..16d6a1f 100644 --- a/vendor/workerman/workerman/Protocols/Dns.php +++ b/vendor/workerman/workerman/Protocols/Dns.php @@ -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;