Example #1
0
    def buildProtocol(self, addr):
        inbound_smtp_connection = ServerFactory.buildProtocol(self, addr)

        inbound_smtp_connection.set_outbound_smtp_connector(
            self.outbound_smtp_connector)

        return inbound_smtp_connection
    def new_protocol_tcp(self):
        """
        Create a new client protocol connected to the server.
        :returns: a IRelayTestClient implementation
        """
        server_factory = ServerFactory()
        server_factory.protocol = TransitConnection
        server_factory.transit = self._transit_server
        server_factory.log_requests = self.log_requests
        server_protocol = server_factory.buildProtocol(('127.0.0.1', 0))

        @implementer(IRelayTestClient)
        class TransitClientProtocolTcp(Protocol):
            """
            Speak the transit client protocol used by the tests over TCP
            """
            _received = b""
            connected = False

            # override Protocol callbacks

            def connectionMade(self):
                self.connected = True
                return Protocol.connectionMade(self)

            def connectionLost(self, reason):
                self.connected = False
                return Protocol.connectionLost(self, reason)

            def dataReceived(self, data):
                self._received = self._received + data

            # IRelayTestClient

            def send(self, data):
                self.transport.write(data)

            def disconnect(self):
                self.transport.loseConnection()

            def reset_received_data(self):
                self._received = b""

            def get_received_data(self):
                return self._received

        client_factory = ClientFactory()
        client_factory.protocol = TransitClientProtocolTcp
        client_protocol = client_factory.buildProtocol(('127.0.0.1', 31337))

        pump = iosim.connect(
            server_protocol,
            iosim.makeFakeServer(server_protocol),
            client_protocol,
            iosim.makeFakeClient(client_protocol),
        )
        pump.flush()
        self._pumps.append(pump)
        return client_protocol
Example #3
0
    def buildProtocol(self, address):
        """
        Builds the protocol to a given address.

        :rtype : Protocol
        """
        p = ServerFactory.buildProtocol(self, address)
        return p
    def buildProtocol(self, addr):
        protocol = ServerFactory.buildProtocol(self, addr)

        # log.msg(protocol)

        # self.client_list[protocol.id] = protocol

        return protocol
 def buildProtocol(self, addr):
     tmpProto = ServerFactory.buildProtocol(self, addr)
     #分配ID
     tmpProto.connectID = self.connectIDIdx
     self.connectIDIdx += 1
     #保存连接
     self.protoList[tmpProto.connectID] = tmpProto
     return tmpProto
Example #6
0
  def buildProtocol(self, addr):
    clients = len(state.connectedMetricReceiverProtocols)
    max_clients = settings.MAX_RECEIVER_CONNECTIONS

    if clients < max_clients:
      return ServerFactory.buildProtocol(self, addr)
    else:
      return None
Example #7
0
def unconnected_proxyserver(mocker):
    mocker.patch("twisted.test.iosim.FakeTransport.startTLS")
    mocker.patch("pappyproxy.proxy.load_certs_from_dir", new=mock_generate_cert)
    factory = ServerFactory()
    factory.protocol = ProxyServer
    protocol = factory.buildProtocol(('127.0.0.1', 0))
    protocol.makeConnection(FakeTransport(protocol, True))
    return protocol
Example #8
0
    def buildProtocol(self, address):
        """
        Builds the protocol to a given address.

        :rtype : Protocol
        """
        p = ServerFactory.buildProtocol(self, address)
        return p
Example #9
0
  def buildProtocol(self, addr):
    from carbon.conf import settings

    # Don't establish the connection if we have reached the limit.
    if len(state.connectedMetricReceiverProtocols) < settings.MAX_RECEIVER_CONNECTIONS:
      return ServerFactory.buildProtocol(self, addr)
    else:
      return None
Example #10
0
 def buildProtocol(self, addr):
     """
     Build the L{NodeServerProtocol} instance and add a callback when the
     connection has been successfully established to the other node.
     """
     p = ServerFactory.buildProtocol(self, addr)
     p._connectDeferred = Deferred()
     p._connectDeferred.addCallback(self._putInCache)
     return p
Example #11
0
    def buildProtocol(self, address):
        """
        Builds the protocol to a given address.

        :rtype : Protocol
        """
        logger.vdebug("Building protocol to address %s", address)
        p = ServerFactory.buildProtocol(self, address)
        return p
Example #12
0
 def buildProtocol(self, addr):
     p = ServerFactory.buildProtocol(self, addr)
     p.service = self
     self.clients[p] = {"from": addr,
                        "connected": time.time(),
                        "rx": 0,
                        "tx": 0,
                        "subscriptions": set()}
     return p
Example #13
0
    def buildProtocol(self, address):
        """
        Builds the protocol to a given address.

        :rtype : Protocol
        """
        logger.debug("Building protocol to address %s", address)
        p = ServerFactory.buildProtocol(self, address)
        return p
	def buildProtocol(self, address):
		proto = ServerFactory.buildProtocol(self, address)
		self.clients[self.next_id] = proto
		if self.client_waiting is None:
			self.client_waiting = self.next_id
		else:
			self.game(self.client_waiting, self.next_id)
			self.client_waiting = None
		self.next_id += 1
		return proto
 def buildProtocol(self, address):
     proto = ServerFactory.buildProtocol(self, address)
     self.clients[self.next_id] = proto
     if self.client_waiting is None:
         self.client_waiting = self.next_id
     else:
         self.game(self.client_waiting, self.next_id)
         self.client_waiting = None
     self.next_id += 1
     return proto
Example #16
0
 def buildProtocol(self, addr):
     p = ServerFactory.buildProtocol(self, addr)
     p.service = self
     self.clients[p] = {
         "from": addr,
         "connected": time.time(),
         "rx": 0,
         "tx": 0,
         "subscriptions": set()
     }
     return p
Example #17
0
def proxyserver(mocker):
    mocker.patch("twisted.test.iosim.FakeTransport.startTLS")
    mocker.patch("pappyproxy.proxy.load_certs_from_dir", new=mock_generate_cert)
    factory = ServerFactory()
    factory.protocol = ProxyServer
    protocol = factory.buildProtocol(('127.0.0.1', 0))
    protocol.makeConnection(FakeTransport(protocol, True))
    protocol.lineReceived('CONNECT https://www.AAAA.BBBB:443 HTTP/1.1')
    protocol.lineReceived('')
    protocol.transport.getOutBuffer()
    return protocol
    def buildProtocol(self, addr):
        password = self.settings.get('iphone', 'password')
        if password:
            protocol = ServerFactory.buildProtocol(self, addr)
            protocol.window = self.window
            protocol.settings = self.settings
            protocol.iocontroller = self.iocontroller
            return protocol

        wx.MessageBox(_('''An iPhone or iPod Touch tried to connect to Task Coach,\n'''
                        '''but no password is set. Please set a password in the\n'''
                        '''iPhone section of the configuration and try again.'''),
                        _('Error'), wx.OK)

        return None
Example #19
0
    def buildProtocol(self, addr):
        password = self.settings.get('iphone', 'password')
        if password:
            protocol = ServerFactory.buildProtocol(self, addr)
            protocol.window = self.window
            protocol.settings = self.settings
            protocol.iocontroller = self.iocontroller
            return protocol

        wx.MessageBox(
            _('''An iPhone or iPod Touch tried to connect to Task Coach,\n'''
              '''but no password is set. Please set a password in the\n'''
              '''iPhone section of the configuration and try again.'''),
            _('Error'), wx.OK)

        return None
Example #20
0
 def buildProtocol(self, addr):
     log.msg('<KB factory>: Building protocol, address=%s...' % str(addr))
     p = ServerFactory.buildProtocol(self, addr)
     p.script_manager = self.script_manager
     p.context_manager = ContextManager(self.context_path)
     return p
Example #21
0
 def buildProtocol(self, addr):
     proto = ServerFactory.buildProtocol(self, addr)
     proto.portal = self.portal
     return proto
Example #22
0
 def buildProtocol(self, *args, **kw):
     log.msg("building server protocol")
     prot = ServerFactory.buildProtocol(self, *args, **kw)
     prot.setPeer(self.client)
     return prot
Example #23
0
 def buildProtocol(self, addr):
     # We expect only one connection, so we only redirect delegate messages to the last instance.
     instance = ServerFactory.buildProtocol(self, addr)
     instance.delegate = self.delegate
     self.last_instance = instance
     return instance
Example #24
0
 def buildProtocol(self, addr):
     proto = ServerFactory.buildProtocol(self, addr)
     return proto
Example #25
0
 def buildProtocol(self, addr):
     protocol = ServerFactory.buildProtocol(self, addr)
     self.reactor.callLater(0, self.result.callback, protocol)
     return protocol
 def buildProtocol(self, addr):
     protocol = ServerFactory.buildProtocol(self, addr)
     protocol.io = self.io
     self.io.addClient(protocol)
     return protocol
Example #27
0
 def buildProtocol(self, addr):
     p = ServerFactory.buildProtocol(self, addr)
     p.addr = addr
     return p
Example #28
0
	def buildProtocol( self, addr ):
		protocol = ServerFactory.buildProtocol( self, addr )
		protocol.SessionHandlerType = ClientSessionHandler

		return protocol
Example #29
0
 def buildProtocol(self, addr):
     self.server = ServerFactory.buildProtocol(self, addr)
     self.server.factory = self
     return self.server
Example #30
0
 def buildProtocol(self, addr):
     # We expect only one connection, so we only redirect delegate messages to the last instance.
     instance = ServerFactory.buildProtocol(self, addr)
     instance.delegate = self.delegate
     self.last_instance = instance
     return instance
Example #31
0
 def buildProtocol(self, addr):
     p = ServerFactory.buildProtocol(self, addr)
     p.portal = self.portal
     return p
Example #32
0
 def buildProtocol(self, addr):
     self.logger.info('Client connected: '+repr(addr))
     return ServerFactory.buildProtocol(self, addr)
Example #33
0
 def buildProtocol(self, addr):
     p = ServerFactory.buildProtocol(self, addr)
     p.test_id = self._test_id()
     return p
Example #34
0
 def buildProtocol(self, addr):
     proto = ServerFactory.buildProtocol(self, addr)
     return proto
Example #35
0
 def buildProtocol(self, addr):
     p = ServerFactory.buildProtocol(self, addr)
     p.theater = Theater.getTheater(gameId)
     return p
Example #36
0
 def buildProtocol(self, addr):
     protocol = ServerFactory.buildProtocol(self, addr)
     self.reactor.callLater(0, self.result.callback, protocol)
     return protocol
Example #37
0
 def buildProtocol(self, addr):
     self.server = ServerFactory.buildProtocol(self, addr)
     self.server.factory = self
     return self.server
Example #38
0
 def buildProtocol(self, addr):
     p = ServerFactory.buildProtocol(self, addr)
     p.addr = addr
     return p
 def buildProtocol(self, addr):
     p = ServerFactory.buildProtocol(self, addr)
     p.context_manager = ContextManager(self.context_path)
     return p
Example #40
0
 def buildProtocol(self, addr):
     log.debug('Creating a protocol for %s', addr)
     return ServerFactory.buildProtocol(self, addr)
Example #41
0
 def buildProtocol(self, addr):
    p = ServerFactory.buildProtocol(self, addr)
    p.theater = Theater.getTheater(gameId)
    return p
Example #42
0
 def buildProtocol(self, addr):
     log.debug('Creating a protocol for %s', addr)
     return ServerFactory.buildProtocol(self, addr)
Example #43
0
 def buildProtocol(self, addr):
     self.proto = ServerFactory.buildProtocol(self, addr)
     self.proto.on_data = self.on_data
     return self.proto