Reduce the exception noise with queries that we dont parse correctly
This commit is contained in:
parent
2a50a1d795
commit
073d95f605
@ -59,8 +59,8 @@ final class DNS extends BaseProtocol
|
||||
public const DNS_TYPE_SOA = 6; // SOA Records
|
||||
public const DNS_TYPE_MX = 15; // MX Records
|
||||
public const DNS_TYPE_TXT = 16; // TXT Records
|
||||
|
||||
public const DNS_TYPE_AAAA = 28; // AAAA Records
|
||||
public const DNS_TYPE_SRV = 33; // SRV Records
|
||||
public const DNS_TYPE_OPT = 41; // OPT Records
|
||||
public const DNS_TYPE_DS = 43; // DS Records (Delegation signer RFC 4034)
|
||||
|
||||
|
@ -50,7 +50,7 @@ final class Query
|
||||
$this->labels = collect();
|
||||
|
||||
while (($len=ord(substr($this->buf,$rx_ptr++,1))) !== 0x00) {
|
||||
$this->labels->push(substr($this->buf,$rx_ptr,$len));
|
||||
$this->labels->push(strtolower(substr($this->buf,$rx_ptr,$len)));
|
||||
$rx_ptr += $len;
|
||||
}
|
||||
|
||||
@ -74,8 +74,8 @@ final class Query
|
||||
if ($this->arcount) {
|
||||
// Additional records, EDNS: https://datatracker.ietf.org/doc/html/rfc6891
|
||||
if (($haystack = strstr(substr($this->buf,$rx_ptr+1+10),"\x00",true)) !== FALSE) {
|
||||
Log::error(sprintf('%s:! DNS additional record format error?',self::LOGKEY));
|
||||
// @todo catch this
|
||||
Log::error(sprintf('%s:! DNS additional record format error?',self::LOGKEY),['buf'=>hex_dump($this->buf)]);
|
||||
return;
|
||||
}
|
||||
|
||||
$this->additional = new RR(substr($this->buf,$rx_ptr,(strlen($haystack) === 0) ? NULL : strlen($haystack)));
|
||||
|
@ -4,6 +4,7 @@ namespace App\Classes\Protocol\DNS;
|
||||
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
use App\Classes\Protocol\DNS;
|
||||
|
||||
@ -26,8 +27,15 @@ final class RR
|
||||
$domain = strstr($buf,"\x00",TRUE);
|
||||
$i += strlen($domain)+1;
|
||||
|
||||
$this->type = Arr::get(unpack('n',substr($buf,$i,2)),1);
|
||||
$this->class = Arr::get(unpack('n',substr($buf,$i+2,2)),1);
|
||||
try {
|
||||
$this->type = Arr::get(unpack('n',substr($buf,$i,2)),1);
|
||||
$this->class = Arr::get(unpack('n',substr($buf,$i+2,2)),1);
|
||||
|
||||
} catch (\ErrorException $e) {
|
||||
Log::error(sprintf('%s:! Error unpacking buffer [%s]',self::LOGKEY,$buf),['buf'=>hex_dump($buf)]);
|
||||
return;
|
||||
}
|
||||
|
||||
$i += 4;
|
||||
|
||||
switch ($this->type) {
|
||||
|
Loading…
Reference in New Issue
Block a user