Add x forward for header

This commit is contained in:
Jeremy Zhang 2018-02-17 17:12:44 +00:00
parent ff401271e6
commit 66b8c7dd09

View File

@ -20,6 +20,9 @@ from titanembeds.discordrest import DiscordREST
discord_api = DiscordREST(config['bot-token']) discord_api = DiscordREST(config['bot-token'])
def get_client_ipaddr(): def get_client_ipaddr():
if request.headers.getlist("X-Forwarded-For"):
ip = request.headers.getlist("X-Forwarded-For")[0]
else:
ip = request.remote_addr ip = request.remote_addr
return hashlib.sha512((config['app-secret'] + ip).encode('utf-8')).hexdigest()[:15] return hashlib.sha512((config['app-secret'] + ip).encode('utf-8')).hexdigest()[:15]