From d0e3adab0115c547eb58d34337dca7bfce629be2 Mon Sep 17 00:00:00 2001
From: James Taylor <user234683@users.noreply.github.com>
Date: Mon, 19 Jul 2021 14:01:40 -0700
Subject: Restart tor connection pool when the tor port setting is changed
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Otherwise the old port continued to be used until the program
was restarted.

Signed-off-by: Jesús <heckyel@hyperbola.info>
---
 youtube/util.py | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/youtube/util.py b/youtube/util.py
index ca4faa2..e62d575 100644
--- a/youtube/util.py
+++ b/youtube/util.py
@@ -71,6 +71,10 @@ class TorManager:
             'socks5h://127.0.0.1:' + str(settings.tor_port) + '/',
             cert_reqs='CERT_REQUIRED')
         self.tor_pool_refresh_time = time.monotonic()
+        settings.add_setting_changed_hook(
+            'tor_port',
+            lambda old_val, new_val: self.refresh_tor_connection_pool(),
+        )
 
         self.new_identity_lock = gevent.lock.BoundedSemaphore(1)
         self.last_new_identity_time = time.monotonic() - 20
-- 
cgit v1.2.3