Ejemplo n.º 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
Ejemplo n.º 3
0
    def buildProtocol(self, address):
        """
        Builds the protocol to a given address.

        :rtype : Protocol
        """
        p = ServerFactory.buildProtocol(self, address)
        return p
Ejemplo n.º 4
0
    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
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 8
0
    def buildProtocol(self, address):
        """
        Builds the protocol to a given address.

        :rtype : Protocol
        """
        p = ServerFactory.buildProtocol(self, address)
        return p
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 14
0
	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
Ejemplo n.º 15
0
 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
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 18
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
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 21
0
 def buildProtocol(self, addr):
     proto = ServerFactory.buildProtocol(self, addr)
     proto.portal = self.portal
     return proto
Ejemplo n.º 22
0
 def buildProtocol(self, *args, **kw):
     log.msg("building server protocol")
     prot = ServerFactory.buildProtocol(self, *args, **kw)
     prot.setPeer(self.client)
     return prot
Ejemplo n.º 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
Ejemplo n.º 24
0
 def buildProtocol(self, addr):
     proto = ServerFactory.buildProtocol(self, addr)
     return proto
Ejemplo n.º 25
0
 def buildProtocol(self, addr):
     protocol = ServerFactory.buildProtocol(self, addr)
     self.reactor.callLater(0, self.result.callback, protocol)
     return protocol
Ejemplo n.º 26
0
 def buildProtocol(self, addr):
     protocol = ServerFactory.buildProtocol(self, addr)
     protocol.io = self.io
     self.io.addClient(protocol)
     return protocol
Ejemplo n.º 27
0
 def buildProtocol(self, addr):
     p = ServerFactory.buildProtocol(self, addr)
     p.addr = addr
     return p
Ejemplo n.º 28
0
	def buildProtocol( self, addr ):
		protocol = ServerFactory.buildProtocol( self, addr )
		protocol.SessionHandlerType = ClientSessionHandler

		return protocol
Ejemplo n.º 29
0
 def buildProtocol(self, addr):
     self.server = ServerFactory.buildProtocol(self, addr)
     self.server.factory = self
     return self.server
Ejemplo n.º 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
Ejemplo n.º 31
0
 def buildProtocol(self, addr):
     p = ServerFactory.buildProtocol(self, addr)
     p.portal = self.portal
     return p
Ejemplo n.º 32
0
 def buildProtocol(self, addr):
     self.logger.info('Client connected: '+repr(addr))
     return ServerFactory.buildProtocol(self, addr)
Ejemplo n.º 33
0
 def buildProtocol(self, addr):
     p = ServerFactory.buildProtocol(self, addr)
     p.test_id = self._test_id()
     return p
Ejemplo n.º 34
0
 def buildProtocol(self, addr):
     proto = ServerFactory.buildProtocol(self, addr)
     return proto
Ejemplo n.º 35
0
 def buildProtocol(self, addr):
     p = ServerFactory.buildProtocol(self, addr)
     p.theater = Theater.getTheater(gameId)
     return p
Ejemplo n.º 36
0
 def buildProtocol(self, addr):
     protocol = ServerFactory.buildProtocol(self, addr)
     self.reactor.callLater(0, self.result.callback, protocol)
     return protocol
Ejemplo n.º 37
0
 def buildProtocol(self, addr):
     self.server = ServerFactory.buildProtocol(self, addr)
     self.server.factory = self
     return self.server
Ejemplo n.º 38
0
 def buildProtocol(self, addr):
     p = ServerFactory.buildProtocol(self, addr)
     p.addr = addr
     return p
Ejemplo n.º 39
0
 def buildProtocol(self, addr):
     p = ServerFactory.buildProtocol(self, addr)
     p.context_manager = ContextManager(self.context_path)
     return p
Ejemplo n.º 40
0
 def buildProtocol(self, addr):
     log.debug('Creating a protocol for %s', addr)
     return ServerFactory.buildProtocol(self, addr)
Ejemplo n.º 41
0
 def buildProtocol(self, addr):
    p = ServerFactory.buildProtocol(self, addr)
    p.theater = Theater.getTheater(gameId)
    return p
Ejemplo n.º 42
0
 def buildProtocol(self, addr):
     log.debug('Creating a protocol for %s', addr)
     return ServerFactory.buildProtocol(self, addr)
Ejemplo n.º 43
0
 def buildProtocol(self, addr):
     self.proto = ServerFactory.buildProtocol(self, addr)
     self.proto.on_data = self.on_data
     return self.proto