trevoro / node-named

DNS Server in node.js
MIT License
356 stars 100 forks source link

Query object may be undefined due to Query.parse() throwing an error in lib/server.js #2

Closed ghost closed 10 years ago

ghost commented 10 years ago

Hello trevoro,

Thanks for writing this library! =)

I've recently encountered an issue with the library as shown in the following error snippet:

There was a client error: ProtocolError: function () {
            return msg || name;
    }
/home/ubuntu/dnsd/node_modules/node-named/lib/server.js:87
            query.respond = function respond() {
                          ^
TypeError: Cannot set property 'respond' of undefined
    at Socket.<anonymous> (/home/ubuntu/dnsd/node_modules/node-named/lib/server.js:87:31)
    at Socket.EventEmitter.emit (events.js:98:17)
    at UDP.onMessage (dgram.js:437:8)

My assumption is that Query.parse() may have thrown an exception. It seems possible, via protocol.decode() when it encounters an invalid DNS record type.

I have implemented a possible fix on my fork; the query event will not be emitted if there is no query object returned.

Please see my pull request for details.

trevoro commented 10 years ago

Hey,

Merged you pull request and things look good. In the future it would be awesome if you could write a test for your merges too.

I'll mark this as closed - Thanks!