mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-06-09 03:42:16 +03:00
Use random number for anonymous uploaderID
This commit is contained in:
parent
91bbe22172
commit
62a18a1655
14
eddn.py
14
eddn.py
@ -1,7 +1,6 @@
|
|||||||
# Export to EDDN
|
# Export to EDDN
|
||||||
|
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
import hashlib
|
|
||||||
import json
|
import json
|
||||||
import numbers
|
import numbers
|
||||||
from os import SEEK_SET, SEEK_CUR, SEEK_END
|
from os import SEEK_SET, SEEK_CUR, SEEK_END
|
||||||
@ -78,15 +77,18 @@ class EDDN:
|
|||||||
replayfile = None
|
replayfile = None
|
||||||
|
|
||||||
def send(self, cmdr, msg):
|
def send(self, cmdr, msg):
|
||||||
salt = config.get('salt')
|
if config.getint('anonymous'):
|
||||||
if not salt:
|
uploaderID = config.get('uploaderID')
|
||||||
salt = uuid.uuid4().hex
|
if not uploaderID:
|
||||||
config.set('salt', salt)
|
uploaderID = uuid.uuid4().hex
|
||||||
|
config.set('uploaderID', uploaderID)
|
||||||
|
else:
|
||||||
|
uploaderID = cmdr.encode('utf-8')
|
||||||
|
|
||||||
msg['header'] = {
|
msg['header'] = {
|
||||||
'softwareName' : '%s [%s]' % (applongname, platform=='darwin' and "Mac OS" or system()),
|
'softwareName' : '%s [%s]' % (applongname, platform=='darwin' and "Mac OS" or system()),
|
||||||
'softwareVersion' : appversion,
|
'softwareVersion' : appversion,
|
||||||
'uploaderID' : config.getint('anonymous') and hashlib.sha1(cmdr.encode('utf-8') + salt).hexdigest() or cmdr.encode('utf-8'),
|
'uploaderID' : uploaderID,
|
||||||
}
|
}
|
||||||
if not msg['message'].get('timestamp'): # already present in journal messages
|
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())))
|
msg['message']['timestamp'] = time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime(config.getint('querytime') or int(time.time())))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user