fix: Log real IP if the header is given by the reverse proxy

pull/79/head
Raphaël Vinot 2020-06-26 10:54:35 +02:00
parent 98495c40a9
commit c81a0c7438
1 changed files with 5 additions and 1 deletions

View File

@ -63,8 +63,12 @@ app.jinja_env.globals.update(sizeof_fmt=sizeof_fmt)
@app.after_request
def after_request(response):
ua = request.headers.get('User-Agent')
real_ip = request.headers.get('X-Real-IP')
if ua:
lookyloo.cache_user_agents(ua, request.remote_addr)
if real_ip:
lookyloo.cache_user_agents(ua, real_ip)
else:
lookyloo.cache_user_agents(ua, request.remote_addr)
return response