From 194b2eae747c9330b993c7b99d8a7d9faa4454ea Mon Sep 17 00:00:00 2001 From: jan Anja Date: Wed, 22 Jun 2022 21:23:58 +0500 Subject: [PATCH] Fix a crash with protected Tor control port (#785) --- app/request.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/request.py b/app/request.py index 8a73e6d..188efa6 100644 --- a/app/request.py +++ b/app/request.py @@ -8,6 +8,7 @@ from requests import Response, ConnectionError import urllib.parse as urlparse import os from stem import Signal, SocketError +from stem.connection import AuthenticationFailure from stem.control import Controller from stem.connection import authenticate_cookie, authenticate_password @@ -63,7 +64,9 @@ def send_tor_signal(signal: Signal) -> bool: c.signal(signal) os.environ['TOR_AVAILABLE'] = '1' return True - except (SocketError, ConnectionRefusedError, ConnectionError): + except (SocketError, AuthenticationFailure, + ConnectionRefusedError, ConnectionError): + # TODO: Handle Tor authentification (password and cookie) os.environ['TOR_AVAILABLE'] = '0' return False