def startDiscovery(self): from shtoom.nat import isBogusAddress, getLocalIPAddress if _ForceStunType is not None: self.natType = _ForceStunType reactor.callLater(0, self._finishedStun) return localAddress = self.transport.getHost().host if isBogusAddress(localAddress): d = getLocalIPAddress() d.addCallback(self._resolveStunServers) else: self._resolveStunServers(localAddress)
def _cb_map_gotUPnP(self, upnp, port): from shtoom.nat import isBogusAddress, getLocalIPAddress # XXX Test that upnp is present self.upnp = upnp # Extract local address from the port locAddr = port.getHost().host if isBogusAddress(locAddr): # lookup local IP. d = getLocalIPAddress() d.addCallback(lambda x: self._cb_map_gotLocalIP(x, port)) else: self._cb_map_gotLocalIP(locAddr, port)