retreive real client IP
This commit is contained in:
parent
af888970f2
commit
f102cc22f1
@ -1,6 +1,6 @@
|
||||
# InstallMgr
|
||||
|
||||
Mini app Flask remplaçant les CGI Sciript de `scodoc.iutv`.
|
||||
Mini-app Flask remplaçant les CGI scripts de `scodoc.iutv`.
|
||||
|
||||
## API
|
||||
|
||||
|
@ -31,11 +31,13 @@ def upload_dump():
|
||||
Réception d'un fichier de dump uploadé
|
||||
"""
|
||||
log = open(LOG_FILENAME, "a")
|
||||
log.write("hello\n")
|
||||
now = datetime.datetime.now()
|
||||
fulltime = now.isoformat()
|
||||
# client addr:
|
||||
remote_addr = request.environ.get("HTTP_X_Real_IP", request.remote_addr)
|
||||
log.write("{} request from {}\n".format(fulltime, remote_addr))
|
||||
remote_addr = request.environ.get("HTTP_X_REAL_IP", request.remote_addr)
|
||||
|
||||
log.write("{fulltime} request from {remote_addr}\n")
|
||||
# Avec seulement alphanum et tiret:
|
||||
clean_deptname = re.sub(r"[^A-Za-z-]", "", request.form["dept_name"])
|
||||
the_file = request.files["file"]
|
||||
@ -105,6 +107,7 @@ def upload_dump():
|
||||
)
|
||||
except:
|
||||
log.write("exception while sending email !\n")
|
||||
log.close()
|
||||
return ("", 204) # ok empty response
|
||||
|
||||
|
||||
@ -161,3 +164,4 @@ def version():
|
||||
)
|
||||
)
|
||||
f.close()
|
||||
return serial
|
||||
|
@ -19,7 +19,7 @@ User=scodoc
|
||||
Group=scodoc
|
||||
WorkingDirectory=/opt/installmgr
|
||||
Environment=FLASK_RUN_PORT=5010
|
||||
ExecStart=/opt/installmgr/venv/bin/gunicorn -b localhost:8010 -w 1 installmgr:app
|
||||
ExecStart=/opt/installmgr/venv/bin/gunicorn -b localhost:8010 -w 2 installmgr:app
|
||||
Restart=always
|
||||
|
||||
[Install]
|
||||
|
Loading…
Reference in New Issue
Block a user