From 62a18a1655f98ba401e38ae7764c04549b542fe2 Mon Sep 17 00:00:00 2001
From: Jonathan Harris <jonathan@marginal.org.uk>
Date: Sat, 6 May 2017 03:02:23 +0100
Subject: [PATCH] Use random number for anonymous uploaderID

---
 eddn.py | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/eddn.py b/eddn.py
index 0443c78d..de35ce6d 100644
--- a/eddn.py
+++ b/eddn.py
@@ -1,7 +1,6 @@
 # Export to EDDN
 
 from collections import OrderedDict
-import hashlib
 import json
 import numbers
 from os import SEEK_SET, SEEK_CUR, SEEK_END
@@ -78,15 +77,18 @@ class EDDN:
         replayfile = None
 
     def send(self, cmdr, msg):
-        salt = config.get('salt')
-        if not salt:
-            salt = uuid.uuid4().hex
-            config.set('salt', salt)
+        if config.getint('anonymous'):
+            uploaderID = config.get('uploaderID')
+            if not uploaderID:
+                uploaderID = uuid.uuid4().hex
+                config.set('uploaderID', uploaderID)
+        else:
+            uploaderID = cmdr.encode('utf-8')
 
         msg['header'] = {
             'softwareName'    : '%s [%s]' % (applongname, platform=='darwin' and "Mac OS" or system()),
             '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
             msg['message']['timestamp'] = time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime(config.getint('querytime') or int(time.time())))