From 66b8c7dd093d0e74f26a7ca3153b0af2779b4da8 Mon Sep 17 00:00:00 2001 From: Jeremy Zhang Date: Sat, 17 Feb 2018 17:12:44 +0000 Subject: [PATCH] Add x forward for header --- webapp/titanembeds/utils.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/webapp/titanembeds/utils.py b/webapp/titanembeds/utils.py index 0f4ab74..d9b5f38 100644 --- a/webapp/titanembeds/utils.py +++ b/webapp/titanembeds/utils.py @@ -20,7 +20,10 @@ from titanembeds.discordrest import DiscordREST discord_api = DiscordREST(config['bot-token']) def get_client_ipaddr(): - ip = request.remote_addr + if request.headers.getlist("X-Forwarded-For"): + ip = request.headers.getlist("X-Forwarded-For")[0] + else: + ip = request.remote_addr return hashlib.sha512((config['app-secret'] + ip).encode('utf-8')).hexdigest()[:15] def generate_session_key():