retreive real client IP

This commit is contained in:
Emmanuel Viennet 2021-09-18 21:27:30 +02:00
parent d3b37bd7cc
commit 803fc1b298

View File

@ -33,8 +33,8 @@ def upload_dump():
log = open(LOG_FILENAME, "a")
now = datetime.datetime.now()
fulltime = now.isoformat()
# shorttime= now.replace(microsecond=0).isoformat()
remote_addr = request.remote_addr # client addr
# client addr:
remote_addr = request.environ.get("HTTP_X_FORWARDED_FOR", request.remote_addr)
log.write("{} request from {}\n".format(fulltime, remote_addr))
# Avec seulement alphanum et tiret:
clean_deptname = re.sub(r"[^A-Za-z-]", "", request.form["dept_name"])