예제 #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)
예제 #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)
예제 #3
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)
예제 #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) 
예제 #5
0
 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)))
예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #11
0
    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)
예제 #12
0
 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)
예제 #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)
예제 #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)
예제 #15
0
 def connectionLost(self, reason):
     """代理服务器请求web服务器时,连接断开了
         ,也要通知并断开代理服务器与客户端的连接"""
     if self.connectedRemote is not None:
         self.connectedRemote.transport.loseConnection()
     Proxy.connectionLost(self, reason)
예제 #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)
예제 #17
0
 def connectionLost(self, reason):
     if self.connectedRemote is not None:
         self.connectedRemote.transport.loseConnection()
     Proxy.connectionLost(self, reason)
예제 #18
0
파일: host_run.py 프로젝트: shauvik/webdiff
 def __init__(self, ds):
     self.ds = ds
     Proxy.__init__(self)
예제 #19
0
 def __init__(self, allowed_address, *args, **kwargs):
     self.allowed_address = allowed_address
     Proxy.__init__(self, *args, **kwargs)
예제 #20
0
 def __init__(self, allowed_address, *args, **kwargs):
     self.allowed_address = allowed_address
     Proxy.__init__(self, *args, **kwargs)
예제 #21
0
 def requestDone(self, request):
     if request.method == 'CONNECT' and self.connectedRemote is not None:
         self.connectedRemote.connectedClient = self
     else:
         Proxy.requestDone(self, request)
예제 #22
0
 def connectionLost(self, reason):
     if self.connectedRemote is not None:
         self.connectedRemote.transport.loseConnection()
     Proxy.connectionLost(self, reason)
예제 #23
0
파일: proxy.py 프로젝트: JonAder/mhqs
 def __init__(self):
     self._tunnel = None
     Proxy.__init__(self)
예제 #24
0
 def connectionLost(self, reason):
     if self._tunnel:
         self._tunnel.transport.loseConnection()
         self._tunnel = None
     Proxy.connectionLost(self, reason)
예제 #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)
예제 #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)
예제 #27
0
 def __init__(self):
     self._tunnelproto = None
     self._sadface = None
     Proxy.__init__(self)
예제 #28
0
 def connectionLost(self, reason):
     """代理服务器请求web服务器时,连接断开了
         ,也要通知并断开代理服务器与客户端的连接"""
     if self.connectedRemote is not None:
         self.connectedRemote.transport.loseConnection()
     Proxy.connectionLost(self, reason)
예제 #29
0
파일: proxy.py 프로젝트: JonAder/mhqs
 def dataReceived(self, data):
     if self._tunnel:
         self._tunnel.transport.write(data)
     else:
         Proxy.dataReceived(self, data)
예제 #30
0
 def requestDone(self, request):
     if self.connectedRemote is not None:
         self.connectedRemote.connectedClient = self
     else:
         Proxy.requestDone(self, request)