当前位置: 首页>>代码示例>>Python>>正文


Python Factory.buildProtocol方法代码示例

本文整理汇总了Python中twisted.internet.protocol.Factory.buildProtocol方法的典型用法代码示例。如果您正苦于以下问题:Python Factory.buildProtocol方法的具体用法?Python Factory.buildProtocol怎么用?Python Factory.buildProtocol使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在twisted.internet.protocol.Factory的用法示例。


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

示例1: buildProtocol

# 需要导入模块: from twisted.internet.protocol import Factory [as 别名]
# 或者: from twisted.internet.protocol.Factory import buildProtocol [as 别名]
 def buildProtocol(self, addr):
     if self.accept_list != None and addr.host not in self.accept_list:
         return None
     p = Factory.buildProtocol(self, addr)
     p.command_cb = self.command_cb
     p.raddr = addr
     return p
开发者ID:JustRight,项目名称:rtpproxy,代码行数:9,代码来源:Cli_server_tcp.py

示例2: buildProtocol

# 需要导入模块: from twisted.internet.protocol import Factory [as 别名]
# 或者: from twisted.internet.protocol.Factory import buildProtocol [as 别名]
 def buildProtocol(self, addr):
     """
     Builds the protocol
     """
     p = Factory.buildProtocol(self, addr)
     p.hub = self.hub
     return p
开发者ID:hagna,项目名称:simplebb,代码行数:9,代码来源:shell.py

示例3: test_connectionCancelledBeforeSecure

# 需要导入模块: from twisted.internet.protocol import Factory [as 别名]
# 或者: from twisted.internet.protocol.Factory import buildProtocol [as 别名]
    def test_connectionCancelledBeforeSecure(self):
        """
        If the connection is cancelled before the SSH transport layer has
        finished key exchange (ie, gotten to the point where we may attempt to
        authenticate), the L{Deferred} returned by
        L{SSHCommandClientEndpoint.connect} fires with a L{Failure} wrapping
        L{CancelledError} and the connection is aborted.
        """
        endpoint = SSHCommandClientEndpoint.newConnection(
            self.reactor, b"/bin/ls -l", b"dummy user",
            self.hostname, self.port, knownHosts=self.knownHosts,
            ui=FixedResponseUI(False))

        factory = Factory()
        factory.protocol = Protocol
        d = endpoint.connect(factory)

        transport = AbortableFakeTransport(None, isServer=False)
        factory = self.reactor.tcpClients[0][2]
        client = factory.buildProtocol(None)
        client.makeConnection(transport)
        d.cancel()

        self.failureResultOf(d).trap(CancelledError)
        self.assertTrue(transport.aborted)
        # Make sure the connection closing doesn't result in unexpected
        # behavior when due to cancellation:
        client.connectionLost(Failure(ConnectionDone()))
开发者ID:AlexanderHerlan,项目名称:syncpy,代码行数:30,代码来源:test_endpoints.py

示例4: buildProtocol

# 需要导入模块: from twisted.internet.protocol import Factory [as 别名]
# 或者: from twisted.internet.protocol.Factory import buildProtocol [as 别名]
 def buildProtocol(self, addr):
     p = Factory.buildProtocol(self, addr)
     
     p.player = {}
     p.player_uuid = self.player_uuid
     p.username = self.username
     
     return p
开发者ID:JohnDoee,项目名称:tidalstream-apiserver-plugins,代码行数:10,代码来源:control.py

示例5: buildProtocol

# 需要导入模块: from twisted.internet.protocol import Factory [as 别名]
# 或者: from twisted.internet.protocol.Factory import buildProtocol [as 别名]
 def buildProtocol(self, addr):
     if self.dead:
         return None
     ip = addr.host
     connections = self.peerConnections.get(ip, 0)
     maxConnections = self.servconfig["client_peer_exempt"][ip] if ip in self.servconfig["client_peer_exempt"] else self.servconfig["client_peer_connections"]
     if maxConnections and connections >= maxConnections:
         log.msg("A client at IP address {} has exceeded the session limit".format(ip))
         return None
     self.peerConnections[ip] = connections + 1
     return Factory.buildProtocol(self, addr)
开发者ID:smillaedler,项目名称:txircd,代码行数:13,代码来源:ircd.py

示例6: start

# 需要导入模块: from twisted.internet.protocol import Factory [as 别名]
# 或者: from twisted.internet.protocol.Factory import buildProtocol [as 别名]
    def start(self):
        """
        Start the socks5 server by listening on the specified TCP ports.
        """
        def build_protocol(_):
            socks5connection = Socks5Connection(self)
            self.sessions.append(socks5connection)
            return socks5connection

        factory = Factory()
        factory.buildProtocol = build_protocol
        self.twisted_port = reactor.listenTCP(self.port, factory)
开发者ID:Tribler,项目名称:tribler,代码行数:14,代码来源:server.py

示例7: test_defaultBuildProtocol

# 需要导入模块: from twisted.internet.protocol import Factory [as 别名]
# 或者: from twisted.internet.protocol.Factory import buildProtocol [as 别名]
 def test_defaultBuildProtocol(self):
     """
     L{Factory.buildProtocol} by default constructs a protocol by calling
     its C{protocol} attribute, and attaches the factory to the result.
     """
     class SomeProtocol(Protocol):
         pass
     f = Factory()
     f.protocol = SomeProtocol
     protocol = f.buildProtocol(None)
     self.assertIsInstance(protocol, SomeProtocol)
     self.assertIdentical(protocol.factory, f)
开发者ID:AlexanderHerlan,项目名称:syncpy,代码行数:14,代码来源:test_protocol.py

示例8: buildProtocol

# 需要导入模块: from twisted.internet.protocol import Factory [as 别名]
# 或者: from twisted.internet.protocol.Factory import buildProtocol [as 别名]
    def buildProtocol(self, addr):
        proto = Factory.buildProtocol(self, addr)
        for prev_proto in self.already_proto:
            assert isinstance(prev_proto.locator, CoordinatorLocatorDecorator), 'Каждый локатор должен быть ' \
                                                                                'декорирован для задания своего ' \
                                                                                'списка incoming_connections'
            assert prev_proto.locator.decorated_locator is self.coordinator_locator, 'координирующий ' \
                                                                                     'локатор должен быть один'
            prev_proto.locator.add_incoming_connection(proto)
            proto.locator.add_incoming_connection(prev_proto)

        # add for the next protos
        self.already_proto.append(proto)
        return proto
开发者ID:musius,项目名称:collaboration,代码行数:16,代码来源:core.py

示例9: buildProtocol

# 需要导入模块: from twisted.internet.protocol import Factory [as 别名]
# 或者: from twisted.internet.protocol.Factory import buildProtocol [as 别名]
 def buildProtocol(self, addr):
     if self.dead:
         return None
     ip = addr.host
     # self.unique_ips.add(ip)
     # self.stats_data["total_connections"] = len(self.unique_ips)
     # if self.app_ip_log:
     #    with open(self.app_ip_log,"w") as f:
     #        f.write(json.dumps(list(self.unique_ips), separators=(',',':')))
     conn = self.peerConnections.get(ip, 0)
     max = self.client_peer_exempt[ip] if ip in self.client_peer_exempt else self.client_peer_connections
     if max and conn >= max:
         return None
     # self.stats_data["connections"] += 1
     self.peerConnections[ip] = conn + 1
     return Factory.buildProtocol(self, addr)
开发者ID:ojii,项目名称:txircd,代码行数:18,代码来源:ircd.py

示例10: test_connectionClosedBeforeSecure

# 需要导入模块: from twisted.internet.protocol import Factory [as 别名]
# 或者: from twisted.internet.protocol.Factory import buildProtocol [as 别名]
    def test_connectionClosedBeforeSecure(self):
        """
        If the connection closes at any point before the SSH transport layer
        has finished key exchange (ie, gotten to the point where we may attempt
        to authenticate), the L{Deferred} returned by
        L{SSHCommandClientEndpoint.connect} fires with a L{Failure} wrapping
        the reason for the lost connection.
        """
        endpoint = SSHCommandClientEndpoint.newConnection(
            self.reactor, b"/bin/ls -l", b"dummy user",
            self.hostname, self.port, knownHosts=self.knownHosts,
            ui=FixedResponseUI(False))

        factory = Factory()
        factory.protocol = Protocol
        d = endpoint.connect(factory)

        transport = StringTransport()
        factory = self.reactor.tcpClients[0][2]
        client = factory.buildProtocol(None)
        client.makeConnection(transport)

        client.connectionLost(Failure(ConnectionDone()))
        self.failureResultOf(d).trap(ConnectionDone)
开发者ID:AlexanderHerlan,项目名称:syncpy,代码行数:26,代码来源:test_endpoints.py

示例11: buildProtocol

# 需要导入模块: from twisted.internet.protocol import Factory [as 别名]
# 或者: from twisted.internet.protocol.Factory import buildProtocol [as 别名]
 def buildProtocol(self, addr):
     if addr.host not in self.only_ip and "0.0.0.0" not in self.only_ip:
         return
     return Factory.buildProtocol(self, addr)
开发者ID:fivemil,项目名称:PulseShop-Server,代码行数:6,代码来源:ws.py

示例12: buildProtocol

# 需要导入模块: from twisted.internet.protocol import Factory [as 别名]
# 或者: from twisted.internet.protocol.Factory import buildProtocol [as 别名]
 def buildProtocol(self, addr):
     self.resetDelay()   # Reset the delay
     self.p = Factory.buildProtocol(self, addr)
     return self.p
开发者ID:Santhanaraman15,项目名称:trunk,代码行数:6,代码来源:client.py

示例13: buildProtocol

# 需要导入模块: from twisted.internet.protocol import Factory [as 别名]
# 或者: from twisted.internet.protocol.Factory import buildProtocol [as 别名]
 def buildProtocol(self, addr):
     prot = Factory.buildProtocol(self, addr)
     self.protocols.append(prot)
     return prot
开发者ID:tmhenry,项目名称:mediaproxy,代码行数:6,代码来源:dispatcher.py

示例14: buildProtocol

# 需要导入模块: from twisted.internet.protocol import Factory [as 别名]
# 或者: from twisted.internet.protocol.Factory import buildProtocol [as 别名]
 def buildProtocol(self, addr):
     p = Factory.buildProtocol(self, addr)
     p.control_session = self.control_session
     return p
开发者ID:lahwran,项目名称:tx_tlsrelay,代码行数:6,代码来源:server.py

示例15: buildProtocol

# 需要导入模块: from twisted.internet.protocol import Factory [as 别名]
# 或者: from twisted.internet.protocol.Factory import buildProtocol [as 别名]
 def buildProtocol(self, addr):
     log.msg("Client connected from:", (addr,))
     protocol = Factory.buildProtocol(self, addr)
     protocol.register(self.map)
     protocol.addr = addr
     return protocol
开发者ID:rbistolfi,项目名称:spacecraft,代码行数:8,代码来源:server.py


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