querying for SOA but got CNAME instead of empty answer or error
deepika-maj opened this issue · comments
here is the code:
$loop = LoopFactory::create();
$executor = new TcpTransportExecutor('8.8.8.8:53', $loop);
$query = new Query('chrome.blogspot.com', Message::TYPE_SOA, Message::CLASS_IN);
$executor->query($query)->then(function (Message $message) {
var_export((array)$message);
});
$loop->run();
and response:
array (
'id' => 35669,
'qr' => true,
'opcode' => 0,
'aa' => false,
'tc' => false,
'rd' => true,
'ra' => true,
'rcode' => 0,
'questions' =>
array (
0 =>
React\Dns\Query\Query::__set_state(array(
'name' => 'chrome.blogspot.com',
'type' => 6,
'class' => 1,
)),
),
'answers' =>
array (
0 =>
React\Dns\Model\Record::__set_state(array(
'name' => 'chrome.blogspot.com',
'type' => 5,
'class' => 1,
'ttl' => 2864,
'data' => 'blogspot.l.googleusercontent.com',
)),
),
'authority' =>
array (
0 =>
React\Dns\Model\Record::__set_state(array(
'name' => 'l.googleusercontent.com',
'type' => 6,
'class' => 1,
'ttl' => 59,
'data' =>
array (
'mname' => 'ns1.google.com',
'rname' => 'dns-admin.google.com',
'serial' => 271311469,
'refresh' => 900,
'retry' => 900,
'expire' => 1800,
'minimum' => 60,
),
)),
),
'additional' =>
array (
),
)
@deepika-maj Thanks for this excellent question!
What you're seeing may be confusing, but is actually by design. The lower-level executor classes will simply expose the DNS data as-is. If the DNS server responds with a CNAME
record instead of your type, it will be returned as-is. This means that you will need to follow the CNAME
and do another lookup depending on your use case.
For most higher-level queries, you would normally use the resolve()
/resolveAll()
methods directory. These methods will take care of resolving any alias names automatically.
I hope this helps 👍
@clue thanks for the clarification