diff --git a/main.py b/main.py index 95febc7..929b0a1 100644 --- a/main.py +++ b/main.py @@ -10,7 +10,7 @@ import sys from ipaddress import AddressValueError, IPv4Address, IPv6Address import cherrypy -from cherrypy.lib.static import serve_file +# from cherrypy.lib.static import serve_file from jinja2 import Template import yaml @@ -59,8 +59,13 @@ class CloudInitApp: try: self.hostinfo = socket.gethostbyaddr(self.remoteip) + forward_lookup = socket.gethostbyname(self.hostinfo[0]) + if forward_lookup != self.remoteip: + self.hostinfo = ('localhost', ) except socket.herror: self.hostinfo = ('localhost', ) + except socket.gaierror: + self.hostinfo = (self.remoteip, ) def _redirect_if_needed(self): filepath = os.path.join(PATH, "data", self.hostinfo[0],