Beispiel #1
0
 def dataReceived(self, data):
     if self.connectedRemote is None:
         Proxy.dataReceived(self, data)
     else:
         # Once proxy is connected, forward all bytes received
         # from the original client to the remote server.
         self.connectedRemote.transport.write(data)
Beispiel #2
0
 def dataReceived(self, data):
     if self._tunnelproto:
         self._tunnelproto.dataReceived(data)
     elif self._sadface:
         self._sadface.transport.write(data)
     else:
         Proxy.dataReceived(self, data)
 def dataReceived(self, data):
     if self.connectedRemote is None:
         Proxy.dataReceived(self, data)
     else:
         # Once proxy is connected, forward all bytes received
         # from the original client to the remote server.
         self.connectedRemote.transport.write(data)
Beispiel #4
0
 def dataReceived(self, data): 
     """ 
     If there is a tunnel connection, forward the stream; otherwise 
     behave just like Proxy. 
     """ 
     if self._tunnelproto is None: 
         Proxy.dataReceived(self, data) 
     else: 
         self._tunnelproto.transport.write(data) 
 def dataReceived(self, data):
     if self.connectedRemote is None:
         log.msg('%d bytes received from origin (client)' % (len(data)))
         Proxy.dataReceived(self, data)
     else:
         # Once proxy is connected, forward all bytes received
         # from the original client to the remote server.
         self.connectedRemote.transport.write(data)
         log.msg('%d bytes transferred to destination (remote)' % (len(data)))
Beispiel #6
0
 def dataReceived(self, data):
     # 数据收到后,如果代理服务器自己的请求,自己接收,
     if self.connectedRemote is None:
         Proxy.dataReceived(self, data)
     else:
         # Once proxy is connected, forward all bytes received
         # from the original client to the remote server.
         # 如果是远程客户端的请求,则将数据传给远程客户端
         self.connectedRemote.transport.write(data)
Beispiel #7
0
 def connectionLost(self, reason):
     """Fired after a connection is closed or lost. Calls
     loseConnection() on the transport as well.
     
     @param reason: Holds the reason, why the connection was lost
     """
     if self.connectedRemote is not None:
         self.connectedRemote.transport.loseConnection()
     Proxy.connectionLost(self, reason)
Beispiel #8
0
 def dataReceived(self, data):
     """ 
     If there is a tunnel connection, forward the stream; otherwise 
     behave just like Proxy. 
     """
     if self._tunnelproto is None:
         Proxy.dataReceived(self, data)
     else:
         self._tunnelproto.transport.write(data)
Beispiel #9
0
 def dataReceived(self, data):
     # 数据收到后,如果代理服务器自己的请求,自己接收,
     if self.connectedRemote is None:
         Proxy.dataReceived(self, data)
     else:
         # Once proxy is connected, forward all bytes received
         # from the original client to the remote server.
         # 如果是远程客户端的请求,则将数据传给远程客户端
         self.connectedRemote.transport.write(data)
Beispiel #10
0
    def requestDone(self, request):
        """requestDone Fires when the first client request is done.

        @param request: The finished request from a client
        @type request: 
        """
        if request.method == 'CONNECT' and self.connectedRemote is not None:
            self.connectedRemote.connectedClient = self
        else:
            Proxy.requestDone(self, request)
    def requestDone(self, request):

        # Only for non HTTPS connections.
        if (request.method != 'CONNECT') and ('content-length' in request.headers):
            log.msg('Content-Length: %d' % int(request.headers['content-length']))
            self.factory.update_usage(request.sentLength)

        if request.method == 'CONNECT' and self.connectedRemote is not None:
            self.connectedRemote.connectedClient = self
        else:
            Proxy.requestDone(self, request)
 def requestDone(self, request):
     if request.method == 'CONNECT' and self.connectedRemote is not None:
         self.connectedRemote.connectedClient = self
         self._handlingRequest = False
         self._producer.resumeProducing()
         if self._savedTimeOut:
             self.setTimeout(self._savedTimeOut)
         data = b''.join(self._dataBuffer)
         self._dataBuffer = []
         self.setLineMode(data)
     else:
         Proxy.requestDone(self, request)
Beispiel #13
0
 def requestDone(self, request):
     if request.method == b'CONNECT' and self.connectedRemote is not None:
         self.connectedRemote.connectedClient = self
         if twisted.version >= Version(twisted.__name__, 16, 3, 0):
             self._handlingRequest = False
             #self._producer.resumeProducing()
             if self._savedTimeOut:
                 self.setTimeout(self._savedTimeOut)
             data = b''.join(self._dataBuffer)
             self._dataBuffer = []
             self.setLineMode(data)
     else:
         Proxy.requestDone(self, request)
Beispiel #14
0
 def dataReceived(self, data):
     """Fires when data is received from the remote. If a CONNECT 
     request was issued, the data is sent directly to the client, 
     else it will be processed by the Proxy class from Twisted.
     
     @param data: Data received from the remote
     """
     if self.connectedRemote is None:
         Proxy.dataReceived(self, data)
     else:
         # Once proxy is connected, forward all bytes received
         # from the original client to the remote server.
         self.connectedRemote.transport.write(data)
Beispiel #15
0
 def connectionLost(self, reason):
     """代理服务器请求web服务器时,连接断开了
         ,也要通知并断开代理服务器与客户端的连接"""
     if self.connectedRemote is not None:
         self.connectedRemote.transport.loseConnection()
     Proxy.connectionLost(self, reason)
Beispiel #16
0
 def requestDone(self, request):
     """connect请求 && 属于远程客户端的请求,则将该客户端改成当前代理服务器"""
     if request.method == 'CONNECT' and self.connectedRemote is not None:
         self.connectedRemote.connectedClient = self
     else:
         Proxy.requestDone(self, request)
 def connectionLost(self, reason):
     if self.connectedRemote is not None:
         self.connectedRemote.transport.loseConnection()
     Proxy.connectionLost(self, reason)
Beispiel #18
0
 def __init__(self, ds):
     self.ds = ds
     Proxy.__init__(self)
Beispiel #19
0
 def __init__(self, allowed_address, *args, **kwargs):
     self.allowed_address = allowed_address
     Proxy.__init__(self, *args, **kwargs)
Beispiel #20
0
 def __init__(self, allowed_address, *args, **kwargs):
     self.allowed_address = allowed_address
     Proxy.__init__(self, *args, **kwargs)
 def requestDone(self, request):
     if request.method == 'CONNECT' and self.connectedRemote is not None:
         self.connectedRemote.connectedClient = self
     else:
         Proxy.requestDone(self, request)
Beispiel #22
0
 def connectionLost(self, reason):
     if self.connectedRemote is not None:
         self.connectedRemote.transport.loseConnection()
     Proxy.connectionLost(self, reason)
Beispiel #23
0
 def __init__(self):
     self._tunnel = None
     Proxy.__init__(self)
 def connectionLost(self, reason):
     if self._tunnel:
         self._tunnel.transport.loseConnection()
         self._tunnel = None
     Proxy.connectionLost(self, reason)
Beispiel #25
0
 def requestDone(self, request):
     if request.method == 'CONNECT' and self.connectedRemote is not None:
         self.connectedRemote.connectedClient = self
     else:
         Proxy.requestDone(self, request)
Beispiel #26
0
 def requestDone(self, request):
     """connect请求 && 属于远程客户端的请求,则将该客户端改成当前代理服务器"""
     if request.method == 'CONNECT' and self.connectedRemote is not None:
         self.connectedRemote.connectedClient = self
     else:
         Proxy.requestDone(self, request)
Beispiel #27
0
 def __init__(self):
     self._tunnelproto = None
     self._sadface = None
     Proxy.__init__(self)
Beispiel #28
0
 def connectionLost(self, reason):
     """代理服务器请求web服务器时,连接断开了
         ,也要通知并断开代理服务器与客户端的连接"""
     if self.connectedRemote is not None:
         self.connectedRemote.transport.loseConnection()
     Proxy.connectionLost(self, reason)
Beispiel #29
0
 def dataReceived(self, data):
     if self._tunnel:
         self._tunnel.transport.write(data)
     else:
         Proxy.dataReceived(self, data)
Beispiel #30
0
 def requestDone(self, request):
     if self.connectedRemote is not None:
         self.connectedRemote.connectedClient = self
     else:
         Proxy.requestDone(self, request)