예제 #1
0
파일: main.py 프로젝트: fawkesley/acproxy
    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
예제 #3
0
    def buildProtocol(self, address):
        """
        Builds the protocol to a given address.

        :rtype : Protocol
        """
        p = ServerFactory.buildProtocol(self, address)
        return p
예제 #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
예제 #6
0
파일: protocols.py 프로젝트: vrg0/carbon
  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
예제 #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
예제 #8
0
    def buildProtocol(self, address):
        """
        Builds the protocol to a given address.

        :rtype : Protocol
        """
        p = ServerFactory.buildProtocol(self, address)
        return p
예제 #9
0
파일: protocols.py 프로젝트: xbernpa/carbon
  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
예제 #10
0
파일: server.py 프로젝트: cybergrind/twotp
 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
예제 #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
예제 #12
0
파일: relay.py 프로젝트: warner/toolbed
 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
예제 #13
0
파일: server.py 프로젝트: elmerfud/StarryPy
    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
예제 #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
예제 #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
예제 #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
예제 #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
예제 #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
예제 #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
예제 #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
예제 #21
0
 def buildProtocol(self, addr):
     proto = ServerFactory.buildProtocol(self, addr)
     proto.portal = self.portal
     return proto
예제 #22
0
 def buildProtocol(self, *args, **kw):
     log.msg("building server protocol")
     prot = ServerFactory.buildProtocol(self, *args, **kw)
     prot.setPeer(self.client)
     return prot
예제 #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
예제 #24
0
 def buildProtocol(self, addr):
     proto = ServerFactory.buildProtocol(self, addr)
     return proto
예제 #25
0
 def buildProtocol(self, addr):
     protocol = ServerFactory.buildProtocol(self, addr)
     self.reactor.callLater(0, self.result.callback, protocol)
     return protocol
예제 #26
0
 def buildProtocol(self, addr):
     protocol = ServerFactory.buildProtocol(self, addr)
     protocol.io = self.io
     self.io.addClient(protocol)
     return protocol
예제 #27
0
 def buildProtocol(self, addr):
     p = ServerFactory.buildProtocol(self, addr)
     p.addr = addr
     return p
예제 #28
0
	def buildProtocol( self, addr ):
		protocol = ServerFactory.buildProtocol( self, addr )
		protocol.SessionHandlerType = ClientSessionHandler

		return protocol
예제 #29
0
 def buildProtocol(self, addr):
     self.server = ServerFactory.buildProtocol(self, addr)
     self.server.factory = self
     return self.server
예제 #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
예제 #31
0
 def buildProtocol(self, addr):
     p = ServerFactory.buildProtocol(self, addr)
     p.portal = self.portal
     return p
예제 #32
0
 def buildProtocol(self, addr):
     self.logger.info('Client connected: '+repr(addr))
     return ServerFactory.buildProtocol(self, addr)
예제 #33
0
 def buildProtocol(self, addr):
     p = ServerFactory.buildProtocol(self, addr)
     p.test_id = self._test_id()
     return p
예제 #34
0
 def buildProtocol(self, addr):
     proto = ServerFactory.buildProtocol(self, addr)
     return proto
예제 #35
0
 def buildProtocol(self, addr):
     p = ServerFactory.buildProtocol(self, addr)
     p.theater = Theater.getTheater(gameId)
     return p
예제 #36
0
 def buildProtocol(self, addr):
     protocol = ServerFactory.buildProtocol(self, addr)
     self.reactor.callLater(0, self.result.callback, protocol)
     return protocol
예제 #37
0
 def buildProtocol(self, addr):
     self.server = ServerFactory.buildProtocol(self, addr)
     self.server.factory = self
     return self.server
예제 #38
0
 def buildProtocol(self, addr):
     p = ServerFactory.buildProtocol(self, addr)
     p.addr = addr
     return p
예제 #39
0
 def buildProtocol(self, addr):
     p = ServerFactory.buildProtocol(self, addr)
     p.context_manager = ContextManager(self.context_path)
     return p
예제 #40
0
파일: server.py 프로젝트: zhilinwww/lbry
 def buildProtocol(self, addr):
     log.debug('Creating a protocol for %s', addr)
     return ServerFactory.buildProtocol(self, addr)
예제 #41
0
파일: cnc4.py 프로젝트: istobran/eaEmu
 def buildProtocol(self, addr):
    p = ServerFactory.buildProtocol(self, addr)
    p.theater = Theater.getTheater(gameId)
    return p
예제 #42
0
파일: server.py 프로젝트: squareinc/lbry
 def buildProtocol(self, addr):
     log.debug('Creating a protocol for %s', addr)
     return ServerFactory.buildProtocol(self, addr)
예제 #43
0
 def buildProtocol(self, addr):
     self.proto = ServerFactory.buildProtocol(self, addr)
     self.proto.on_data = self.on_data
     return self.proto