• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python srvconnect.SRVConnector类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中twisted.names.srvconnect.SRVConnector的典型用法代码示例。如果您正苦于以下问题:Python SRVConnector类的具体用法?Python SRVConnector怎么用?Python SRVConnector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了SRVConnector类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: _getConnection

 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
开发者ID:Urthen,项目名称:Legacy-FritBot,代码行数:7,代码来源:client.py


示例2: start

 def start(self):       
    myJid = jid.JID(self.username)
    factory = client.XMPPClientFactory(myJid, self.password)
    factory.addBootstrap(xmlstream.STREAM_AUTHD_EVENT, self.authd)       
    connector = SRVConnector(reactor, 'xmpp-client', self.jabberserver, factory)       
    reactor.callLater(5, self.stop)
    connector.connect()    
开发者ID:cool-shark,项目名称:crashxmpp,代码行数:7,代码来源:crashxmpp.py


示例3: connectSRV

 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
开发者ID:esh,项目名称:invaders,代码行数:9,代码来源:protocol.py


示例4: connect

 def connect(self):
     if callable(self.override):
         self.override(self.factory)
     elif not self._isQueryNeeded():
         self.factory.doStart()
         self.factory.startedConnecting(self)
         self._reallyConnect()
     else:
         SRVConnector.connect(self)
开发者ID:cwaldbieser,项目名称:ldaptor,代码行数:9,代码来源:ldapconnector.py


示例5: __init__

 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()
开发者ID:BillAndersan,项目名称:twisted,代码行数:9,代码来源:xmpp_client.py


示例6: __init__

 def __init__(self, client_reactor, domain, factory):
     """ Init """
     SRVConnector.__init__(self, client_reactor, 'xmpp-client', domain, factory)
     if isinstance(domain, unicode):
         warnings.warn(
             "Domain argument to XMPPClientConnector should be bytes, "
             "not unicode",
             stacklevel=2)
         domain = domain.encode('ascii')
     self.timeout = [1,3]
开发者ID:cvogler,项目名称:punjab,代码行数:10,代码来源:session.py


示例7: __init__

 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()
开发者ID:samsoft00,项目名称:careervacancy,代码行数:10,代码来源:xmpp_client.py


示例8: __init__

 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
开发者ID:speedyleion,项目名称:vobby,代码行数:11,代码来源:infinoted.py


示例9: __init__

    def __init__(self, reactor, dn, factory,
                 overrides=None, bindAddress=None):
        if not isinstance(dn, distinguishedname.DistinguishedName):
            dn = distinguishedname.DistinguishedName(stringValue=dn)
        if overrides is None:
            overrides = {}
        self.override = self._findOverRide(dn, overrides)

        domain = dn.getDomainName() or ''
        SRVConnector.__init__(self, reactor,
                  'ldap', domain, factory,
                  connectFuncKwArgs={'bindAddress': bindAddress})
开发者ID:cwaldbieser,项目名称:ldaptor,代码行数:12,代码来源:ldapconnector.py


示例10: connect

    def connect(self, protocolFactory):
        def _canceller(deferred):
            connector.stopConnecting()
            deferred.errback(
                error.ConnectingCancelledError(connector.getDestination()))

        try:
            wf = _WrappingFactory(protocolFactory, _canceller)
            connector = SRVConnector(self._reactor, self._service, 
                self._domain, wf, protocol=self._protocol)
            connector.connect()
            return wf._onConnection
        except:
            return defer.fail()
开发者ID:Izeni,项目名称:ParselTONE,代码行数:14,代码来源:endpoints.py


示例11: pickServer

    def pickServer(self):
        if self.override is None:
            overriddenHost, overriddenPort = None, None
        else:
            overriddenHost, overriddenPort = self.override

        if (overriddenHost is not None
            and (overriddenPort is not None
                 or self.domain is None)):
            host = overriddenHost
            port = overriddenPort
        else:
            host, port = SRVConnector.pickServer(self)
            if overriddenHost is not None:
                host = overriddenHost
            if overriddenPort is not None:
                port = overriddenPort

        try:
            port = int(port)
        except ValueError:
            pass

        assert host is not None
        if port is None:
            port = 389
        return host, port
开发者ID:cwaldbieser,项目名称:ldaptor,代码行数:27,代码来源:ldapconnector.py


示例12: connect

    def connect(self, server_address, service=None, protocol='tcp'):
        """
        Connect to the given server_address.

        Without the 'service' keyword, the server_address can be formatted
        as HOST[:PORT] (if no port given, 8800 will be assumed).

        If 'service' is used, it must be the name of a service to look up
        using a DNS SRV record at the server_address (in this case, no port is
        expected in the server_address). The 'protocol' is also sent used in
        the DNS SRV lookup.

        The 'protocol' keyword is ignored if 'service' is not used.

        Examples:
            c = Client()

            # connect to example.com at port 8800
            c.connect('example.com')

            # connect to example.com at port 45
            c.connect('example.com:45')

            # look up the host and port using SRV, passing 'SIP' as the
            ## service name to the DNS SRV host at example.com
            c.connect('example.com', service='SIP')

         TODO: Twisted uses it's own lookup cache that appears to be
         cleared when the process terminates. I am unsure whether that
         cache respects SRV TTL; if not, long-living reconnecting
         clients *might* not get a new lookup. Further testing is needed
         to determine this.
        """
        self.ip = server_address
        if service:
            connector = SRVConnector(reactor, service, server_address,
                self.factory, protocol=protocol)
            connector.connect()
        else:
            self.host, self.port = utils.parse_host_port(server_address, 8800)
            try:
                reactor.connectTCP(self.host, self.port, self.factory)
            except error.ConnectionRefusedError, e:
                logger.error(e)
                # wraps the error in a slightly more generic ClientError
                ## and reraises
                raise ClientError(str(e))
开发者ID:Izeni,项目名称:ParselTONE,代码行数:47,代码来源:base.py


示例13: pickServer

    def pickServer(self):
        host, port = SRVConnector.pickServer(self)

        if not self.servers and not self.orderedServers:
            # no SRV record, fall back..
            port = int(config()['xmpp']['port'])

        return host, port
开发者ID:Ri0n,项目名称:Hermes,代码行数:8,代码来源:xmpp.py


示例14: pickServer

    def pickServer(self):
        host, port = SRVConnector.pickServer(self)

        if not self.servers and not self.orderedServers:
            # no SRV record, fall back..
            port = 5222

        return host, port
开发者ID:kkszysiu,项目名称:pynktalk,代码行数:8,代码来源:xmpp_client.py


示例15: pickServer

    def pickServer(self):
        assert self.servers is not None
        assert self.orderedServers is not None

        if not self.servers and not self.orderedServers:
            # no SRV record, fall back..
            return self.domain, 2855

        return SRVConnector.pickServer(self)
开发者ID:grengojbo,项目名称:python-msrplib,代码行数:9,代码来源:connect.py


示例16: connectSSL

    def connectSSL(self, server_address, cert_path, cert_chain_path=None,
            service=None, protocol='ssl'):
        """
        Connect to the given server_address.

        See the docstring for Client.connect() for more information.
        """
        self.ip = server_address

        # verify that the given key/cert files actually exist
        if not os.path.exists(cert_path):
            raise ClientError('Cert file %r does not exist!' % cert_path)
        if cert_chain_path and not os.path.exists(cert_chain_path):
            raise ClientError('Cert chain file %r does not exist!' % \
                cert_chain_path)

        class CtxFactory(ssl.ClientContextFactory):
            def getContext(self):
                self.method = SSL.SSLv23_METHOD
                ctx = ssl.ClientContextFactory.getContext(self)
                if cert_chain_path:
                    ctx.use_certificate_chain_file(cert_chain_path)
                ctx.use_certificate_file(cert_path)
                return ctx

        if service:
            connector = SRVConnector(reactor, service, server_address,
                self.factory, protocol=protocol, connectFuncName='connectSSL',
                connectFuncArgs=(CtxFactory(),))
            connector.connect()
        else:
            self.host, self.port = utils.parse_host_port(server_address, 2220)
            try:
                reactor.connectSSL(self.host, self.port, self.factory,
                    CtxFactory())
            except error.ConnectionRefusedError, e:
                logger.error(e)
                # wraps the error in a slightly more generic ClientError
                ## and reraises
                raise ClientError(str(e))
开发者ID:Izeni,项目名称:ParselTONE,代码行数:40,代码来源:base.py


示例17: init

    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 = "%[email protected]%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)
开发者ID:MtalentTime,项目名称:aires,代码行数:13,代码来源:XMPP.py


示例18: pickServer

    def pickServer(self):
        """
        Pick a server and port to make the connection.
        """
        host, port = SRVConnector.pickServer(self)

        if port == 5223 and ssl:
            context = ssl.ClientContextFactory()
            context.method = ssl.SSL.SSLv23_METHOD

            self.connectFuncName = 'connectSSL'
            self.connectFuncArgs = (context,)
        return host, port
开发者ID:apostolelvis,项目名称:punjab,代码行数:13,代码来源:session.py


示例19: pickServer

    def pickServer(self):
        """
        Pick a server and port to make the connection.
        """
        host, port = SRVConnector.pickServer(self)

        if not self.servers and not self.orderedServers:
            # no SRV record, fall back..
            port = 5222
        if port == 5223 and xmlstream.ssl:
            context = xmlstream.ssl.ClientContextFactory()
            context.method = xmlstream.ssl.SSL.SSLv23_METHOD
            
            self.connectFunc = 'connectSSL'
            self.connectFuncArgs = (context)
        return host, port
开发者ID:PADGETS-EU,项目名称:padgets-repo,代码行数:16,代码来源:session.py


示例20: __init__

 def __init__(self, reactor, domain, factory, credentials, tls_reactor):
     self.tls_reactor = tls_reactor
     SRVConnector.__init__(self, reactor, 'xmpp-net', str(domain), factory,
         connectFuncName='connectTLS', connectFuncKwArgs={'credentials':credentials})
开发者ID:BillTheBest,项目名称:xmppserver,代码行数:4,代码来源:net.py



注:本文中的twisted.names.srvconnect.SRVConnector类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python aot.jellyToSource函数代码示例发布时间:2022-05-27
下一篇:
Python client.Resolver类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap