Closed nkakouros closed 5 years ago
This might be because the server just assumes that the DNS packet has a question, your packet has none. This should be an easy fix.
@tterranigma give the latest commit a go
It fails again with:
[nikos@localhost PHP-DNS-SERVER]$ sudo php example/example.php
[2018-11-21T23:05:14+00:00] info: Server started.
[2018-11-21T23:05:14+00:00] info: Listening on 0.0.0.0:53
PHP Notice: Undefined offset: 0 in /home/nikos/Projects/PHP-DNS-SERVER/src/Resolver/SystemResolver.php on line 44
PHP Fatal error: Uncaught Error: Call to a member function getName() on null in /home/nikos/Projects/PHP-DNS-SERVER/src/Resolver/SystemResolver.php:46
Stack trace:
#0 /home/nikos/Projects/PHP-DNS-SERVER/src/Resolver/StackableResolver.php(35): yswery\DNS\Resolver\SystemResolver->getAnswer(Array)
#1 /home/nikos/Projects/PHP-DNS-SERVER/src/Server.php(129): yswery\DNS\Resolver\StackableResolver->getAnswer(Array)
#2 /home/nikos/Projects/PHP-DNS-SERVER/src/Server.php(102): yswery\DNS\Server->handleQueryFromStream('\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00')
#3 /home/nikos/Projects/PHP-DNS-SERVER/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php(123): yswery\DNS\Server->onMessage('\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00', '127.0.0.1:48652', Object(React\Datagram\Socket))
#4 /home/nikos/Projects/PHP-DNS-SERVER/vendor/react/datagram/src/Socket.php(75): Evenement\EventEmitter->emit('message', Array)
#5 /home/nikos/Projects/PHP-DNS-SERVER/vendor/react/event-loop/src/StreamSelectLoop.php(238): React\Datagram\ in /home/nikos/Projects/PHP-DNS-SERVER/src/Resolver/SystemResolver.php on line 46
@tterranigma give the latest commit a go - I'm having issues with my system so I can't run my linux boxes at the moment to test
Yep! It worked!
[nikos@localhost PHP-DNS-SERVER]$ sudo nmap 127.0.0.1 -sU -p 53
Starting Nmap 7.70 ( https://nmap.org ) at 2018-11-23 22:28 CET
Nmap scan report for nikos-laptop.localdomain (127.0.0.1)
Host is up (0.0038s latency).
PORT STATE SERVICE
53/udp open domain
Nmap done: 1 IP address (1 host up) scanned in 0.14 seconds
Thank you for the time you devoted on this issue!
Issue resolved in v1.1.3
Steps to reproduce:
sudo php examples/example.php
sudo nmap -sU -p53 127.0.0.1
This crashes the dns server with the following trace:
Running
tcpdump -i lo port 53 -vvv
in parallel with nmap, shows the following captured packets being sent from nmap:Here is a screenshot of the packet in wireshark: