Catch bad DNS queries and reduce exception logging

This commit is contained in:
2023-10-04 15:50:24 +11:00
parent 0fcb628c11
commit d82f8ac8b3
2 changed files with 11 additions and 5 deletions

View File

@@ -61,7 +61,7 @@ final class Query
} catch (\Exception $e) {
Log::error(sprintf('%s:! Unpack failed: Buffer: [%s] (%d), RXPTR [%d]',self::LOGKEY,hex_dump($this->buf),strlen($this->buf),$rx_ptr));
return;
throw $e;
}
$rx_ptr += 4;
@@ -82,9 +82,8 @@ final class Query
$rx_ptr += $this->additional->length;
}
if (strlen($this->buf) !== $rx_ptr) {
dd(['query remaining'=>strlen($this->buf)-$rx_ptr,'hex'=>hex_dump(substr($this->buf,$rx_ptr))]);
}
if (strlen($this->buf) !== $rx_ptr)
throw new \Exception(sprintf('! DNS Buffer still has [%d]: %s',strlen($this->buf)-$rx_ptr,hex_dump(substr($this->buf,$rx_ptr))));
}
public function __get($key)