mirror of
https://git.deluge-torrent.org/deluge
synced 2025-10-02 15:08:36 +00:00
[Core] Respect listen_reuse_port to randomize port on startup
The `listen_reuse_port` config is never respected in deluge. Practically, this means that users cannot randomize the listen port on startup. Before this change, this is what happens in `_set_listen_on`: 1. On run 1, `listen_random_port` is empty. 2. A random port is chosen, and its value is written into `listen_random_port` in `core.conf`. 3. On all subsequent runs, `deluged` reads `core.conf` and picks up `listen_random_port` from the previous run, so `listen_random_port` will never be randomized again. To fix this, we should read `listen_reuse_port` and if it's `false`, always disregard the current `listen_random_port` and randomly pick a new value for it. Signed-off-by: Gavin Zhao <git@gzgz.dev> Closes: https://github.com/deluge-torrent/deluge/pull/477
This commit is contained in:
parent
22e9adbc31
commit
3a806973ea
1 changed files with 4 additions and 1 deletions
|
@ -200,7 +200,10 @@ class PreferencesManager(component.Component):
|
|||
def __set_listen_on(self):
|
||||
"""Set the ports and interface address to listen for incoming connections on."""
|
||||
if self.config['random_port']:
|
||||
if not self.config['listen_random_port']:
|
||||
if (
|
||||
not self.config['listen_reuse_port']
|
||||
or not self.config['listen_random_port']
|
||||
):
|
||||
self.config['listen_random_port'] = random.randrange(49152, 65525)
|
||||
listen_ports = [
|
||||
self.config['listen_random_port']
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue