[Twisted-Python] Specifying the local port for a twisted.names DNS query or resolver

exarkun at twistedmatrix.com exarkun at twistedmatrix.com
Tue Jun 14 14:01:47 EDT 2011


On 04:25 pm, anton at iki.fi wrote:
>I have external requirements that force me to issue DNS queries from a
>specific local port range. I'm looking for a way to use the
>twisted.names resolver but I need to specify a local port for a query
>or set the local port range for all queries. I appreciate that the
>local port randomization is there for good security reasons, but for
>my application I do not care. I would be grateful for any tips or
>guidelines on how to achieve this.
>
>For some ancient Twisted version I got it working by monkey patching
>twisted.names.dns.DNSDatagramProtocol.startListening() to this effect.
>This ugly hack of mine does not work anymore for any recent version of
>Twisted. Is there a right way to do it?

We'd be happy to have such a feature officially supported.  Would you 
like to work on a patch that adds a tested, documented hook for 
selecting the source port?

Jean-Paul



More information about the Twisted-Python mailing list