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
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
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
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