Fix a crash with protected Tor control port

This commit is contained in:
Anna “CyberTailor” 2022-06-15 05:09:41 +05:00
parent 2600ad5a05
commit 29975db1ea
No known key found for this signature in database
GPG Key ID: E7B76EDC50864BB1

View File

@ -7,6 +7,7 @@ from requests import Response, ConnectionError
import urllib.parse as urlparse import urllib.parse as urlparse
import os import os
from stem import Signal, SocketError from stem import Signal, SocketError
from stem.connection import AuthenticationFailure
from stem.control import Controller from stem.control import Controller
MAPS_URL = 'https://maps.google.com/maps' MAPS_URL = 'https://maps.google.com/maps'
@ -43,7 +44,9 @@ def send_tor_signal(signal: Signal) -> bool:
c.signal(signal) c.signal(signal)
os.environ['TOR_AVAILABLE'] = '1' os.environ['TOR_AVAILABLE'] = '1'
return True return True
except (SocketError, ConnectionRefusedError, ConnectionError): except (SocketError, AuthenticationFailure,
ConnectionRefusedError, ConnectionError):
# TODO: Handle Tor authentification (password and cookie)
os.environ['TOR_AVAILABLE'] = '0' os.environ['TOR_AVAILABLE'] = '0'
return False return False