def startService(self): self.connector = SRVConnector(self.reactor, 'xmpp-client', self.jid.host, self.factory, defaultPort=5222) self.connector.connect()
def _getConnection(self): if self.host: return reactor.connectTCP(self.host, self.port, self.factory) else: c = SRVConnector(reactor, 'xmpp-client', self.domain, self.factory) c.connect() return c
def connectSRV(self, service, domain, *args, **kwargs): SRVConnector = kwargs.pop('ConnectorClass', None) if SRVConnector is None: from twisted.names.srvconnect import SRVConnector gtransport, factory = self._make_transport_and_factory() c = SRVConnector(self.reactor, service, domain, factory, *args, **kwargs) c.connect() gtransport._init_transport() return gtransport
def __init__(self, reactor, jid, secret): self.reactor = reactor f = client.XMPPClientFactory(jid, secret) f.addBootstrap(xmlstream.STREAM_CONNECTED_EVENT, self.connected) f.addBootstrap(xmlstream.STREAM_END_EVENT, self.disconnected) f.addBootstrap(xmlstream.STREAM_AUTHD_EVENT, self.authenticated) f.addBootstrap(xmlstream.INIT_FAILED_EVENT, self.init_failed) connector = SRVConnector(reactor, "xmpp-client", jid.host, f, defaultPort=5222) connector.connect() self.finished = Deferred()
def __init__(self, client_jid, secret): f = client.XMPPClientFactory(client_jid, secret) f.addBootstrap(xmlstream.STREAM_CONNECTED_EVENT, self.connected) f.addBootstrap(xmlstream.STREAM_END_EVENT, self.disconnected) f.addBootstrap(xmlstream.STREAM_AUTHD_EVENT, self.authenticated) f.addBootstrap(xmlstream.INIT_FAILED_EVENT, self.init_failed) connector = SRVConnector(reactor, 'xmpp-client', client_jid.host, f, defaultPort=5222) connector.connect()
def __init__(self, service): jid = JID('127.0.0.1') f = client.XMPPClientFactory(jid, '') f.addBootstrap(xmlstream.STREAM_CONNECTED_EVENT, self.connected) f.addBootstrap(xmlstream.STREAM_AUTHD_EVENT, self.authenticated) connector = SRVConnector(reactor, 'xmpp-client', jid.host, f, defaultPort=6523) connector.connect() self.finished = Deferred() self.files = {} self.service = service
def init(self): self.username, self.server = self.mirror('username').split('@') self.password = self.mirror('password') listener = self.parent().get_listener(self._id) self.resource = listener['resource'] self.nickname = listener['nickname'] jid = "%s@%s/%s" % (self.username, self.server, self.resource) self.jid = JID(jid) self.f = client.XMPPClientFactory(self.jid, self.password) self.con = SRVConnector(reactor, 'xmpp-client', self.jid.host, self.f, defaultPort=5222)
def fetch_server_key(server_name, ssl_context_factory): """Fetch the keys for a remote server.""" factory = SynapseKeyClientFactory() SRVConnector( reactor, "matrix", server_name, factory, protocol="tcp", connectFuncName="connectSSL", defaultPort=443, connectFuncKwArgs=dict(contextFactory=ssl_context_factory)).connect() server_key, server_certificate = yield factory.remote_key defer.returnValue((server_key, server_certificate))
0] print "If the hostname and port are not specified, the MSRP relay will be discovered" print "through the the _msrps._tcp.domain SRV record. If a hostname is specified but" print "no port, the default port of 2855 will be used." else: username, domain = sys.argv[1].split("@", 1) cred = X509Credentials(None, None) cred.verify_peer = False ctx = TLSContext(cred) password = getpass() if len(sys.argv) == 2: factory = MSRPFileReceiverFactory(username, password, URI(domain, use_tls=True)) connector = SRVConnector(reactor, "msrps", domain, factory, connectFuncName="connectTLS", connectFuncArgs=[ctx]) connector.connect() else: relay_host = sys.argv[2] if len(sys.argv) == 4: relay_port = int(sys.argv[3]) else: relay_port = 2855 factory = MSRPFileReceiverFactory( username, password, URI(relay_host, port=relay_port, use_tls=True)) reactor.connectTLS(relay_host, relay_port, factory, ctx) reactor.run()
def clientCreator(factory): domain = factory.authenticator.jid.host c = SRVConnector(reactor, 'xmpp-client', domain, factory) c.connect() return factory.deferred
def _do_connect(): self.connector = SRVConnector(reactor, 'xmpp-client', self.server, c) self.connector.pickServer = lambda: (self.server, 5222) self.connector.connect()