def validateConnection(self, thisHost, otherHost, sid, key): """ Validate an incoming XMPP server-to-server connection. """ log.debug("validating connection from %s (sid=%r)" % (otherHost, sid)) def connected(xs): # Set up stream for immediate disconnection. def disconnect(_): xs.transport.loseConnection() xs.addObserver(xmlstream.STREAM_AUTHD_EVENT, disconnect) xs.addObserver(xmlstream.INIT_FAILED_EVENT, disconnect) authenticator = server.XMPPServerVerifyAuthenticator(thisHost, otherHost, sid, key) factory = server.DeferredS2SClientFactory(authenticator) factory.addBootstrap(xmlstream.STREAM_CONNECTED_EVENT, connected) factory.logTraffic = self.logTraffic return server.initiateS2S(factory)
def initiateOutgoingStream(self, thisHost, otherHost): """ Initiate an outgoing XMPP server-to-server connection. """ def resetConnecting(_): self._outgoingConnecting.remove((thisHost, otherHost)) if (thisHost, otherHost) in self._outgoingConnecting: return authenticator = server.XMPPServerConnectAuthenticator( thisHost, otherHost, self.secret) factory = server.DeferredS2SClientFactory(authenticator) factory.addBootstrap(xmlstream.STREAM_AUTHD_EVENT, self.outgoingInitialized) factory.logTraffic = self.logTraffic self._outgoingConnecting.add((thisHost, otherHost)) d = server.initiateS2S(factory) d.addBoth(resetConnecting) return d
def validateConnection(self, thisHost, otherHost, sid, key): """ Validate an incoming XMPP server-to-server connection. """ log.debug("validating connection from %s (sid=%r)" % (otherHost, sid)) def connected(xs): # Set up stream for immediate disconnection. def disconnect(_): xs.transport.loseConnection() xs.addObserver(xmlstream.STREAM_AUTHD_EVENT, disconnect) xs.addObserver(xmlstream.INIT_FAILED_EVENT, disconnect) authenticator = server.XMPPServerVerifyAuthenticator( thisHost, otherHost, sid, key) factory = server.DeferredS2SClientFactory(authenticator) factory.addBootstrap(xmlstream.STREAM_CONNECTED_EVENT, connected) factory.logTraffic = self.logTraffic return server.initiateS2S(factory)
def initiateOutgoingStream(self, thisHost, otherHost): """ Initiate an outgoing XMPP server-to-server connection. """ def resetConnecting(_): self._outgoingConnecting.remove((thisHost, otherHost)) if (thisHost, otherHost) in self._outgoingConnecting: return authenticator = server.XMPPServerConnectAuthenticator(thisHost, otherHost, self.secret) factory = server.DeferredS2SClientFactory(authenticator) factory.addBootstrap(xmlstream.STREAM_AUTHD_EVENT, self.outgoingInitialized) factory.logTraffic = self.logTraffic self._outgoingConnecting.add((thisHost, otherHost)) d = server.initiateS2S(factory) d.addBoth(resetConnecting) return d