1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-14 16:27:13 +03:00

Use random salt

This commit is contained in:
Jonathan Harris 2017-05-04 16:15:01 +01:00
parent 9bbcbc7f78
commit 91bbe22172

View File

@ -11,6 +11,7 @@ import re
import requests
from sys import platform
import time
import uuid
if platform != 'win32':
from fcntl import lockf, LOCK_EX, LOCK_NB
@ -33,7 +34,6 @@ class EDDN:
UPLOAD = 'http://eddn-gateway.elite-markets.net:8080/upload/'
REPLAYPERIOD = 400 # Roughly two messages per second, accounting for send delays [ms]
REPLAYFLUSH = 20 # Update log on disk roughly every 10 seconds
salt = 'SDC Harry Potter'
def __init__(self, parent):
self.parent = parent
@ -78,10 +78,15 @@ class EDDN:
replayfile = None
def send(self, cmdr, msg):
salt = config.get('salt')
if not salt:
salt = uuid.uuid4().hex
config.set('salt', salt)
msg['header'] = {
'softwareName' : '%s [%s]' % (applongname, platform=='darwin' and "Mac OS" or system()),
'softwareVersion' : appversion,
'uploaderID' : config.getint('anonymous') and hashlib.md5(cmdr.encode('utf-8')+EDDN.salt.encode('utf-8')).hexdigest() or cmdr.encode('utf-8'),
'uploaderID' : config.getint('anonymous') and hashlib.sha1(cmdr.encode('utf-8') + salt).hexdigest() or cmdr.encode('utf-8'),
}
if not msg['message'].get('timestamp'): # already present in journal messages
msg['message']['timestamp'] = time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime(config.getint('querytime') or int(time.time())))