[Twisted-Python] Handeling unresolved DNS queries?

exarkun at twistedmatrix.com exarkun at twistedmatrix.com
Thu Oct 22 16:38:06 EDT 2009


On 07:00 pm, jesper at taxboel.dk wrote:
>Hi Jean-Paul,
>
>I guess my focus is right when it comes to redirecting clients.
>
>Im hooking into
>
>DNSDatagramProtocol.writeMessage(self, message, address):
>
>And I guess thats OK?

Depends what "OK" is supposed to mean.
>
>But when it comes to bogus domains, I guess i could use:
>
>DNSServerFactory.gotResolverError(self, failure, protocol, message,
>address):

I don't know why you should have to do that.
>My problem is now how I construct a redirect package and channel it 
>back to
>the client.
>
>Do you think that is a sensible approach? -and do you hava a pointer on 
>how
>to find the associated client.

It would probably be a lot easier and more robust to implement a 
completely new custom resolver that *wraps* an existing resolver, rather 
than trying to extend an existing resolver via a subclass.  This removes 
many irrelevant implementation details from consideration (such as 
writeMessage and gotResolverError) and gives you an obvious place to put 
your redirect logic - in an errback on the Deferred returned by one of 
the wrapped resolver's lookup/query methods.

Jean-Paul



More information about the Twisted-Python mailing list