From da881d49c3d76e5ee5858c9822b79eb780d0294b Mon Sep 17 00:00:00 2001 From: Anders Blomdell <anders.blomdell@control.lth.se> Date: Fri, 17 Nov 2023 18:53:20 +0100 Subject: [PATCH] Add workaround for (bogus) reverse address lookups --- src/mio/filecache.py | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/mio/filecache.py b/src/mio/filecache.py index b5bfd4b..a9c55b2 100755 --- a/src/mio/filecache.py +++ b/src/mio/filecache.py @@ -76,10 +76,26 @@ class Unalias: byaddr.add(sa[0]) pass self.by_name[host] = set() - for name,_,_ in map(socket.gethostbyaddr, byaddr): - self.by_name[host].add(str(name)) + for addr in byaddr: + # Temporary fix for totally broken design + # we should not rely on reverse lookups since that + # mostly fails for local addresses, we should implemennt + # handling of mirrorlists/metalinks + try: + name,_,_ = socket.gethostbyaddr(addr) + self.by_name[host].add(str(name)) + pass + except: + pass pass pass + if not self.by_name[host]: + # Temporary fix for totally broken design + # we should not rely on reverse lookups since that + # mostly fails for local addresses, we should implemennt + # handling of mirrorlists/metalinks + self.by_name[host].add(host) + pass return sorted(self.by_name[host]) def __call__(self, url): @@ -161,7 +177,7 @@ class FileCache: return f def loadfile(self, path, *name, mode=None): - if not path in self.loader: + if not path in self.loader: # Create loader for new path up = urlparse(path) url = urlunparse((up.scheme, up.netloc,'','','','')) -- GitLab