Tweaks to random ports code.

This commit is contained in:
Alex Dedul 2007-08-03 04:23:02 +00:00
parent 6d8864338f
commit 12fe0930b3
1 changed files with 9 additions and 20 deletions

View File

@ -855,25 +855,14 @@ class Manager:
for pref in PREF_FUNCTIONS: for pref in PREF_FUNCTIONS:
if PREF_FUNCTIONS[pref] is not None: if PREF_FUNCTIONS[pref] is not None:
if (PREF_FUNCTIONS[pref] == PREF_FUNCTIONS["listen_on"]): if pref == "listen_on" and self.get_pref("random_port"):
if self.get_pref("random_port") == False: import random
PREF_FUNCTIONS[pref](self.get_pref(pref))
else: randrange = lambda: random.randrange(49152, 65535)
if deluge_core.listening_port() != 0:
for i in xrange(int(self.get_pref("listen_on")[0]),\ ports = [randrange(), randrange()]
int(self.get_pref("listen_on")[1])): ports.sort()
if deluge_core.listening_port() != i: deluge_core.set_listen_on(ports)
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: else:
PREF_FUNCTIONS[pref](self.get_pref(pref)) PREF_FUNCTIONS[pref](self.get_pref(pref))