Hash IP Address to protect them, like what discord does

This commit is contained in:
Jeremy Zhang 2017-04-12 00:36:05 -07:00
parent 3ed0b10ed7
commit 8fe63dee0f
2 changed files with 5 additions and 3 deletions

View File

@ -67,7 +67,7 @@
<th>Username</th> <th>Username</th>
<th>Discrim</th> <th>Discrim</th>
<th>Last Visit</th> <th>Last Visit</th>
<th>IP Address</th> <th>IP Address Hash</th>
<th>Banned Timestamp</th> <th>Banned Timestamp</th>
<th>Banned by</th> <th>Banned by</th>
<th>Banned Reason</th> <th>Banned Reason</th>

View File

@ -6,15 +6,17 @@ from flask_limiter import Limiter
from config import config from config import config
import random import random
import string import string
import hashlib
discord_api = DiscordREST(config['bot-token']) discord_api = DiscordREST(config['bot-token'])
cache = Cache() cache = Cache()
def get_client_ipaddr(): def get_client_ipaddr():
if "X-Real-IP" in request.headers: # pythonanywhere specific if "X-Real-IP" in request.headers: # pythonanywhere specific
return request.headers['X-Real-IP'] ip = request.headers['X-Real-IP']
else: # general else: # general
return request.remote_addr ip = request.remote_addr
return hashlib.sha512(config['app-secret'] + ip).hexdigest()[:15]
def generate_session_key(): def generate_session_key():
sess = session.get("sessionunique", None) sess = session.get("sessionunique", None)