[Shtoom] possible typo in shtoom/stun.py

Antoine Pitrou solipsis at pitrou.net
Wed Aug 17 14:35:51 CEST 2005


Hi,

We are re-using Shtoom's STUN implementation in our LGPL'd project
(http://solipsis.netofpeers.net/) and I've found a likely typo in
shtoom/stun.py.
In the StunDiscoveryProtocol class, the __init__ resolves the servers'
host name sequentially (which can take some time if one the DNS servers
does not answer):
        self.servers = [(socket.gethostbyname(host), port)
                                            for host, port in servers]

whereas there is another method which is supposed to resolve them in
parallel afterwards:

    def _resolveStunServers(self, localAddress):
        self.localAddress = localAddress
        # reactor.resolve the hosts!
        for host, port in self.servers:
            d = reactor.resolve(host)
            d.addCallback(lambda x,p=port: self.initialStunRequest((x, p)))

I suppose one of these two resolutions is redundant and useless. Is
there a reason for doing them both in sequence?
In my code, I've happily disabled the first one.

Regards

Antoine.





More information about the Shtoom mailing list