LJPc-solutions / Pure-PHP-DoH-Client

Retrieve DNS records via DoH in PHP
GNU General Public License v3.0
5 stars 0 forks source link

Error when resolving an domain name #2

Open crdffrance opened 3 weeks ago

crdffrance commented 3 weeks ago

Hello,

I have a new problem when i trying to resolve an domain.

The PHP request with your library :

<?php
use LJPc\DoH\DNS;
use LJPc\DoH\DNSType;
use LJPc\DoH\Servers\Quad9;

require __DIR__ . '/vendor/autoload.php';

$result  = DNS::query( 'push.prod.netflix.com', DNSType::NS(), Quad9::class );
    $answers = $result->getAnswers();
    foreach ( $answers as $answer ) {
        echo $answer->value . "\n";
    }

The PHP Error :

PHP Fatal error:  Uncaught RuntimeException: Too many recursions, something is wrong with the response from all nameservers in /Users/user/Desktop/dns_doh_daemon/dnstest/vendor/ljpc/pure-php-doh-client/src/DNS.php:40
Stack trace:
#0 /Users/user/Desktop/dns_doh_daemon/dnstest/vendor/ljpc/pure-php-doh-client/src/DNS.php(91): LJPc\DoH\DNS::query('push.prod.netfl...', Object(LJPc\DoH\Types\NS), 'LJPc\\DoH\\Server...', 6)
#1 /Users/user/Desktop/dns_doh_daemon/dnstest/vendor/ljpc/pure-php-doh-client/src/DNS.php(91): LJPc\DoH\DNS::query('push.prod.netfl...', Object(LJPc\DoH\Types\NS), 'LJPc\\DoH\\Server...', 5)
#2 /Users/user/Desktop/dns_doh_daemon/dnstest/vendor/ljpc/pure-php-doh-client/src/DNS.php(91): LJPc\DoH\DNS::query('push.prod.netfl...', Object(LJPc\DoH\Types\NS), 'LJPc\\DoH\\Server...', 4)
#3 /Users/user/Desktop/dns_doh_daemon/dnstest/vendor/ljpc/pure-php-doh-client/src/DNS.php(91): LJPc\DoH\DNS::query('push.prod.netfl...', Object(LJPc\DoH\Types\NS), 'LJPc\\DoH\\Server...', 3)
#4 /Users/user/Desktop/dns_doh_daemon/dnstest/vendor/ljpc/pure-php-doh-client/src/DNS.php(91): LJPc\DoH\DNS::query('push.prod.netfl...', Object(LJPc\DoH\Types\NS), 'LJPc\\DoH\\Server...', 2)
#5 /Users/user/Desktop/dns_doh_daemon/dnstest/test.php(8): LJPc\DoH\DNS::query('push.prod.netfl...', Object(LJPc\DoH\Types\NS), 'LJPc\\DoH\\Server...')
#6 {main}
  thrown in /Users/user/Desktop/dns_doh_daemon/dnstest/vendor/ljpc/pure-php-doh-client/src/DNS.php on line 40

Fatal error: Uncaught RuntimeException: Too many recursions, something is wrong with the response from all nameservers in /Users/user/Desktop/dns_doh_daemon/dnstest/vendor/ljpc/pure-php-doh-client/src/DNS.php:40
Stack trace:
#0 /Users/user/Desktop/dns_doh_daemon/dnstest/vendor/ljpc/pure-php-doh-client/src/DNS.php(91): LJPc\DoH\DNS::query('push.prod.netfl...', Object(LJPc\DoH\Types\NS), 'LJPc\\DoH\\Server...', 6)
#1 /Users/user/Desktop/dns_doh_daemon/dnstest/vendor/ljpc/pure-php-doh-client/src/DNS.php(91): LJPc\DoH\DNS::query('push.prod.netfl...', Object(LJPc\DoH\Types\NS), 'LJPc\\DoH\\Server...', 5)
#2 /Users/user/Desktop/dns_doh_daemon/dnstest/vendor/ljpc/pure-php-doh-client/src/DNS.php(91): LJPc\DoH\DNS::query('push.prod.netfl...', Object(LJPc\DoH\Types\NS), 'LJPc\\DoH\\Server...', 4)
#3 /Users/user/Desktop/dns_doh_daemon/dnstest/vendor/ljpc/pure-php-doh-client/src/DNS.php(91): LJPc\DoH\DNS::query('push.prod.netfl...', Object(LJPc\DoH\Types\NS), 'LJPc\\DoH\\Server...', 3)
#4 /Users/user/Desktop/dns_doh_daemon/dnstest/vendor/ljpc/pure-php-doh-client/src/DNS.php(91): LJPc\DoH\DNS::query('push.prod.netfl...', Object(LJPc\DoH\Types\NS), 'LJPc\\DoH\\Server...', 2)
#5 /Users/user/Desktop/dns_doh_daemon/dnstest/test.php(8): LJPc\DoH\DNS::query('push.prod.netfl...', Object(LJPc\DoH\Types\NS), 'LJPc\\DoH\\Server...')
#6 {main}
  thrown in /Users/user/Desktop/dns_doh_daemon/dnstest/vendor/ljpc/pure-php-doh-client/src/DNS.php on line 40

And the logs from the DNS Server:

2024-10-28 21:18:18,281 [INFO] 127.0.0.1 - - [28/Oct/2024 21:18:18] "GET /dns-query?dns=q80BAAABAAAAAAAABHB1c2gEcHJvZAduZXRmbGl4A2NvbQAAAgAB HTTP/1.1" 200 -
2024-10-28 21:18:18,283 [INFO] Received request with method GET and parameters ImmutableMultiDict([('dns', 'q80BAAABAAAAAAAABHB1c2gEcHJvZAduZXRmbGl4A2NvbQAAAgAB')])
2024-10-28 21:18:18,283 [DEBUG] Binary DNS query (GET dns): abcd0100000100000000000004707573680470726f64076e6574666c697803636f6d0000020001
2024-10-28 21:18:18,283 [DEBUG] Parsed DNS Query (GET dns):
id 43981
opcode QUERY
rcode NOERROR
flags RD
;QUESTION
push.prod.netflix.com. IN NS
;ANSWER
;AUTHORITY
;ADDITIONAL
2024-10-28 21:18:18,283 [DEBUG] Generated cache key: d5aafce65f14fea531bf609aebbd7341935334a02ca8b7a0a574515d16444125
2024-10-28 21:18:18,283 [DEBUG] Generated cache key: d5aafce65f14fea531bf609aebbd7341935334a02ca8b7a0a574515d16444125
2024-10-28 21:18:18,283 [DEBUG] In-memory cache hit for key d5aafce65f14fea531bf609aebbd7341935334a02ca8b7a0a574515d16444125.
2024-10-28 21:18:18,283 [INFO] Response found in cache for key d5aafce65f14fea531bf609aebbd7341935334a02ca8b7a0a574515d16444125.
2024-10-28 21:18:18,284 [DEBUG] Cached DNS Response:
id 43981
opcode QUERY
rcode NOERROR
flags QR RD RA
edns 0
payload 1452
option Generic 12
;QUESTION
push.prod.netflix.com. IN NS
;ANSWER
push.prod.netflix.com. 300 IN CNAME push.prod.dradis.netflix.com.
push.prod.dradis.netflix.com. 60 IN CNAME push.prod.eu-west-1.internal.dradis.netflix.com.
push.prod.eu-west-1.internal.dradis.netflix.com. 60 IN CNAME pushy-prod-nlb4-888783e50761c9f4.elb.eu-west-1.amazonaws.com.
;AUTHORITY
elb.eu-west-1.amazonaws.com. 24 IN SOA ns-1566.awsdns-03.co.uk. awsdns-hostmaster.amazon.com. 1 7200 900 1209600 60
;ADDITIONAL
2024-10-28 21:18:18,284 [INFO] 127.0.0.1 - - [28/Oct/2024 21:18:18] "GET /dns-query?dns=q80BAAABAAAAAAAABHB1c2gEcHJvZAduZXRmbGl4A2NvbQAAAgAB HTTP/1.1" 200 -

How can I correct this problem?

If you need more information, I can give it to you. Thanks in advance for the fix.

Regards,

Lars- commented 3 weeks ago

Hi!

I've tested your code, and I get this result: image

So it seems to be working just fine. What version of the library are you using and can you try without the Quad9::class parameter?