Add forward DNS lookup check
This commit is contained in:
parent
0ee0ac4936
commit
12ee0ab3ec
7
main.py
7
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],
|
||||
|
|
Loading…
Reference in New Issue
Block a user