diff --git a/ChangeLog b/ChangeLog index 4bc14ee51..badc7562c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,6 +8,7 @@ there to allow acting upon them. * Enforced the use of the "deluge.plugins" namespace to reduce package names clashing beetween regular packages and deluge plugins. + * Fix potential for host_id collision when creating hostlist entries. ==== Core ==== * Make the distinction between adding to the session new unmanaged torrents diff --git a/deluge/ui/hostlist.py b/deluge/ui/hostlist.py index fa6155538..10d7063b5 100644 --- a/deluge/ui/hostlist.py +++ b/deluge/ui/hostlist.py @@ -11,8 +11,7 @@ from __future__ import unicode_literals import logging import os -import time -from hashlib import sha1 +import uuid from socket import gaierror, gethostbyname from twisted.internet import defer @@ -31,7 +30,7 @@ LOCALHOST = ('127.0.0.1', 'localhost') def default_hostlist(): """Create a new hosts key for hostlist with a localhost entry""" - host_id = sha1(str(time.time()).encode('utf8')).hexdigest() + host_id = uuid.uuid4().hex username, password = get_localhost_auth() return {'hosts': [(host_id, DEFAULT_HOST, DEFAULT_PORT, username, password)]} @@ -132,7 +131,7 @@ class HostList(object): validate_host_info(hostname, port) self.check_info_exists(hostname, port, username) - host_id = sha1(str(time.time())).hexdigest() + host_id = uuid.uuid4().hex self.config['hosts'].append((host_id, hostname, port, username, password)) self.config.save() return host_id