From f9f1b95a4ea9ed640ccc134bab156f458aaaebc5 Mon Sep 17 00:00:00 2001 From: Marcos Pinto Date: Fri, 3 Aug 2007 06:20:36 +0000 Subject: [PATCH] get dht back working for now --- src/core.py | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/src/core.py b/src/core.py index 49d761b77..75ddb616d 100644 --- a/src/core.py +++ b/src/core.py @@ -855,17 +855,28 @@ class Manager: for pref in PREF_FUNCTIONS: if PREF_FUNCTIONS[pref] is not None: - if pref == "listen_on" and self.get_pref("random_port"): - import random - - randrange = lambda: random.randrange(49152, 65535) - - ports = [randrange(), randrange()] - ports.sort() - deluge_core.set_listen_on(ports) + if (PREF_FUNCTIONS[pref] == PREF_FUNCTIONS["listen_on"]): + if self.get_pref("random_port") == False: + PREF_FUNCTIONS[pref](self.get_pref(pref)) + else: + if deluge_core.listening_port() != 0: + for i in xrange(int(self.get_pref("listen_on")[0]),\ + int(self.get_pref("listen_on")[1])): + if deluge_core.listening_port() != i: + pass + else: + import random + ports = [random.randrange(49152, 65535), random.randrange(49152, 65535)] + ports.sort() + deluge_core.set_listen_on(ports) + else: + import random + ports = [random.randrange(49152, 65535), random.randrange(49152, 65535)] + ports.sort() + deluge_core.set_listen_on(ports) else: PREF_FUNCTIONS[pref](self.get_pref(pref)) - + # We need to reapply priorities to files after preferences were # changed for unique_ID in self.unique_IDs: