From 8fe63dee0f21dcda22e74527a49e33ef57755585 Mon Sep 17 00:00:00 2001 From: Jeremy Zhang Date: Wed, 12 Apr 2017 00:36:05 -0700 Subject: [PATCH] Hash IP Address to protect them, like what discord does --- titanembeds/templates/administrate_guild.html.j2 | 2 +- titanembeds/utils.py | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/titanembeds/templates/administrate_guild.html.j2 b/titanembeds/templates/administrate_guild.html.j2 index 81aef22..84ed3d2 100644 --- a/titanembeds/templates/administrate_guild.html.j2 +++ b/titanembeds/templates/administrate_guild.html.j2 @@ -67,7 +67,7 @@ Username Discrim Last Visit - IP Address + IP Address Hash Banned Timestamp Banned by Banned Reason diff --git a/titanembeds/utils.py b/titanembeds/utils.py index d738e81..cfe9c93 100644 --- a/titanembeds/utils.py +++ b/titanembeds/utils.py @@ -6,15 +6,17 @@ from flask_limiter import Limiter from config import config import random import string +import hashlib discord_api = DiscordREST(config['bot-token']) cache = Cache() def get_client_ipaddr(): if "X-Real-IP" in request.headers: # pythonanywhere specific - return request.headers['X-Real-IP'] + ip = request.headers['X-Real-IP'] else: # general - return request.remote_addr + ip = request.remote_addr + return hashlib.sha512(config['app-secret'] + ip).hexdigest()[:15] def generate_session_key(): sess = session.get("sessionunique", None)