ruby-dns / net-dns

Net::DNS is a DNS library written in Ruby.
http://net-dns.rubyforge.org
Other
165 stars 43 forks source link

Drop duplicate query ID handling #39

Closed ebroder closed 12 years ago

ebroder commented 12 years ago

Protection against the Kaminsky attack requires query IDs to be random, but it doesn't require them to be unique. And since net-dns opens a new socket for each query it performs, it doesn't rely on the uniqueness of the query ID to map requests to responses.

Requiring unique query IDs limits net-dns to only making 65535 lookups before it starts spinning in circles, trying to generate a query ID it hasn't seen before, when in fact they have all been generated.

So instead, generate random query IDs, but don't require them to be unique.

weppos commented 12 years ago

Hi @ebroder, thanks for the patch! Is seems that the error Header::DuplicateIDError is no longer in use, we can remove it.

If you can make this change, then I'll merge the patch.

Thanks.

ebroder commented 12 years ago

@weppos Thanks for the quick review - I've pushed an update that drops the exception class.

weppos commented 12 years ago

Merged, thank you! I'll release a new version later today. I want to take the time to cleanup a little bit the Header class and make it less Ruby 1.6 style, now that we attacked it.