From 29975db1eaf97a35fe5cbc0afa36751f21fb7802 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anna=20=E2=80=9CCyberTailor=E2=80=9D?= Date: Wed, 15 Jun 2022 05:09:41 +0500 Subject: [PATCH] Fix a crash with protected Tor control port --- app/request.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/request.py b/app/request.py index d222c45..64850fb 100644 --- a/app/request.py +++ b/app/request.py @@ -7,6 +7,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 MAPS_URL = 'https://maps.google.com/maps' @@ -43,7 +44,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