예제 #1
0
	def __init__(self, client, host, port, bind, method, request, logger):
		self.client = client
		self.sock = self._connect(host, port, bind)
		self.host = host
		self.port = port
		self.method = method
		self.w_buffer = request
		self.log = logger
		self.ipv4 = isipv4(host)
예제 #2
0
파일: worker.py 프로젝트: matt2005/exaproxy
 def __init__(self, client_id, host, port, bind, method, request, logger):
     self.client_id = client_id
     self.sock = self._connect(host, port, bind)
     self.host = host
     self.port = port
     self.method = method
     self.w_buffer = request
     self.log = logger
     self.ipv4 = isipv4(host)
예제 #3
0
	def getDownloader (self, client, host, port, command, request):
		downloader = self.byclient.get(client, None)
		if downloader:
			# NOTE: with pipeline, consequent request could go to other sites if the browser knows we are a proxy
			# NOTE: therefore the second request could reach the first site
			# NOTE: and we could kill the connection before the data is fully back to the client
			# NOTE: in practice modern browser are too clever and test for it !
			if host != downloader.host or port != downloader.port:
				self.endClientDownload(client)
				downloader = None
			else:
				newdownloader = False

		if isipv4(host):
			bind = self.configuration.tcp4.bind
		elif isipv6(host):
			bind = self.configuration.tcp6.bind
		else:
			# should really never happen
			self.log.critical('the host IP address is neither IPv4 or IPv6 .. what year is it ?')
			return None, False

		if downloader is None:
			if self.configuration.security.deny:
				# deny connecton to the deny list
				if ':' in host:
					pr = 6
					high,low = struct.unpack('!QQ',socket.inet_pton(socket.AF_INET6,host))
					ip = (high << 64) + low
				else:
					pr = 4
					ip = struct.unpack('!L',socket.inet_pton(socket.AF_INET,host))[0]

				for proto, start, end in self.configuration.security.deny:
					if pr != proto:
						continue
					if start <= ip <= end:
						return None, False

			# supervisor.local is replaced when interface are changed, so do not cache or reference it in this class
			if host in self.supervisor.local:
				for h,p in self.configuration.security.local:
					if (h == '*' or h == host) and (p == '*' or p == port):
						break
				else:
					# we did not break
					return None, False

			downloader = self.downloader_factory(client, host, port, bind, command, request, self.log)
			newdownloader = True

		if downloader.sock is None:
			return None, False

		return downloader, newdownloader
예제 #4
0
	def __init__(self, name, sock, peer, logger, max_buffer, proxied):
		self.name = name
		self.ipv4 = isipv4(sock.getsockname()[0])
		self.sock = sock
		self.peer = peer
		self.reader = self._read(sock, max_buffer, proxied=proxied)
		self.writer = self._write(sock)
		self.w_buffer = ''
		self.log = logger

		# start the _read coroutine
		self.reader.next()
예제 #5
0
파일: http.py 프로젝트: jbfavre/exaproxy
	def __init__(self, name, sock, peer, logger, max_buffer):
		self.name = name
		self.ipv4 = isipv4(sock.getsockname()[0])
		self.sock = sock
		self.peer = peer
		self.reader = self._read(sock,max_buffer)
		self.writer = self._write(sock)
		self.w_buffer = ''

		self.log = logger

		# start the _read coroutine
		self.reader.next()
예제 #6
0
파일: icap.py 프로젝트: Safe3/exaproxy
	def __init__(self, name, sock, peer, logger, max_buffer):
		self.name = name
		self.ipv4 = isipv4(sock.getsockname()[0])
		self.sock = sock
		self.peer = peer
		self.reader = self._read(sock,max_buffer)
		self.writer = self._write(sock)
		self.w_buffer = ''

		self.icap_parser = ICAPParser(configuration={})
		self.log = logger

		# start the _read coroutine
		self.reader.next()
예제 #7
0
파일: worker.py 프로젝트: j3tm0t0/exaproxy
    def __init__(self, name, sock, peer, logger, max_buffer):
        self.name = name
        self.ipv4 = isipv4(sock.getsockname()[0])
        self.sock = sock
        self.peer = peer
        self.reader = self._read(sock, max_buffer)
        self.writer = self._write(sock)
        self.w_buffer = ""

        self.log = logger
        self.blockupload = None

        # start the _read coroutine
        self.reader.next()
예제 #8
0
    def __init__(self, name, sock, peer, logger, max_buffer, proxied):
        addr, port = sock.getsockname()
        self.name = name
        self.sock = sock
        self.peer = peer
        self.accept_addr = addr
        self.accept_port = port
        self.ipv4 = isipv4(addr)
        self.reader = self._read(sock, max_buffer, proxied=proxied)
        self.writer = self._write(sock)
        self.w_buffer = ''

        self.log = logger

        # start the _read coroutine
        self.reader.next()
예제 #9
0
    def getDownloader(self, client_id, host, port, command, request):
        downloader = self.byclientid.get(client_id, None)
        if downloader:
            # NOTE: with pipeline, consequent request could go to other sites if the browser knows we are a proxy
            # NOTE: therefore the second request could reach the first site
            # NOTE: and we could kill the connection before the data is fully back to the client
            # NOTE: in practice modern browser are too clever and test for it !
            if host != downloader.host or port != downloader.port:
                self.endClientDownload(client_id)
                downloader = None
            else:
                newdownloader = False

        if isipv4(host):
            bind = self.configuration.tcp4.bind
        elif isipv6(host):
            bind = self.configuration.tcp6.bind
        else:
            # should really never happen
            self.log.critical(
                'the host IP address is neither IPv4 or IPv6 .. what year is it ?'
            )
            return None, False

        if downloader is None:
            # supervisor.local is replaced when interface are changed, so do not cache or reference it in this class
            if host in self.supervisor.local:
                for h, p in self.configuration.security.local:
                    if (h == '*' or h == host) and (p == '*' or p == port):
                        break
                else:
                    # we did not break
                    return None, False

            downloader = self.downloader_factory(client_id, host, port, bind,
                                                 command, request, self.log)
            newdownloader = True

        if downloader.sock is None:
            return None, False

        return downloader, newdownloader
예제 #10
0
파일: manager.py 프로젝트: eckeman/exaproxy
	def getDownloader(self, client_id, host, port, command, request):
		downloader = self.byclientid.get(client_id, None)
		if downloader:
			# NOTE: with pipeline, consequent request could go to other sites if the browser knows we are a proxy
			# NOTE: therefore the second request could reach the first site
			# NOTE: and we could kill the connection before the data is fully back to the client
			# NOTE: in practice modern browser are too clever and test for it !
			if host != downloader.host or port != downloader.port:
				self.endClientDownload(client_id)
				downloader = None
			else:
				newdownloader = False

		if isipv4(host):
			bind = self.configuration.tcp4.bind
		elif isipv6(host):
			bind = self.configuration.tcp6.bind
		else:
			# should really never happen
			self.log.critical('the host IP address is neither IPv4 or IPv6 .. what year is it ?')
			return None, False

		if downloader is None:
			# supervisor.local is replaced when interface are changed, so do not cache or reference it in this class
			if host in self.supervisor.local:
				for h,p in self.configuration.security.local:
					if (h == '*' or h == host) and (p == '*' or p == port):
						break
				else:
					# we did not break
					return None, False

			downloader = self.downloader_factory(client_id, host, port, bind, command, request, self.log)
			newdownloader = True

		if downloader.sock is None:
			return None, False

		return downloader, newdownloader
예제 #11
0
    def getDownloader(self, client, host, port, command, request):
        downloader = self.byclient.get(client, None)
        if downloader:
            # NOTE: with pipeline, consequent request could go to other sites if the browser knows we are a proxy
            # NOTE: therefore the second request could reach the first site
            # NOTE: and we could kill the connection before the data is fully back to the client
            # NOTE: in practice modern browser are too clever and test for it !
            if host != downloader.host or port != downloader.port:
                self.endClientDownload(client)
                downloader = None
            else:
                newdownloader = False

        if isipv4(host):
            bind = self.configuration.tcp4.bind
        elif isipv6(host):
            bind = self.configuration.tcp6.bind
        else:
            # should really never happen
            self.log.critical(
                'the host IP address is neither IPv4 or IPv6 .. what year is it ?'
            )
            return None, False

        if downloader is None:
            if self.configuration.security.deny:
                # deny connecton to the deny list
                if ':' in host:
                    pr = 6
                    high, low = struct.unpack(
                        '!QQ', socket.inet_pton(socket.AF_INET6, host))
                    ip = (high << 64) + low
                else:
                    pr = 4
                    ip = struct.unpack('!L',
                                       socket.inet_pton(socket.AF_INET,
                                                        host))[0]

                for proto, start, end in self.configuration.security.deny:
                    if pr != proto:
                        continue
                    if start <= ip <= end:
                        return None, False

            # supervisor.local is replaced when interface are changed, so do not cache or reference it in this class
            if host in self.supervisor.local:
                for h, p in self.configuration.security.local:
                    if (h == '*' or h == host) and (p == '*' or p == port):
                        break
                else:
                    # we did not break
                    return None, False

            downloader = self.downloader_factory(client, host, port, bind,
                                                 command, request, self.log)
            newdownloader = True

        if downloader.sock is None:
            return None, False

        return downloader, newdownloader