Improve support for stateful Tor sessions
This commit is contained in:
parent
531f5cdf3c
commit
6dc6b0af48
2 changed files with 7 additions and 2 deletions
|
|
@ -51,3 +51,4 @@ class Constants:
|
|||
|
||||
HV_TOR_CONTROL_SOCKET_PATH: Final[str] = f'{HV_TOR_SESSION_STATE_HOME}/tor.sock'
|
||||
HV_TOR_PROCESS_IDENTIFIER_PATH: Final[str] = f'{HV_TOR_SESSION_STATE_HOME}/tor.pid'
|
||||
HV_TOR_INSTANCE_LOCK_PATH: Final[str] = f'{HV_TOR_SESSION_STATE_HOME}/lock'
|
||||
|
|
|
|||
|
|
@ -289,6 +289,8 @@ class ConnectionController:
|
|||
controller.authenticate()
|
||||
|
||||
except (FileNotFoundError, stem.SocketError, TypeError, IndexError):
|
||||
|
||||
ConnectionController.terminate_tor_connection()
|
||||
raise TorServiceInitializationError('The dedicated Tor service could not be initialized.')
|
||||
|
||||
for session_state in SessionStateController.all():
|
||||
|
|
@ -299,8 +301,9 @@ class ConnectionController:
|
|||
@staticmethod
|
||||
def terminate_tor_connection():
|
||||
|
||||
process_identifier_file = Path(Constants.HV_TOR_PROCESS_IDENTIFIER_PATH)
|
||||
control_socket_file = Path(Constants.HV_TOR_CONTROL_SOCKET_PATH)
|
||||
process_identifier_file = Path(Constants.HV_TOR_PROCESS_IDENTIFIER_PATH)
|
||||
instance_lock_file = Path(Constants.HV_TOR_INSTANCE_LOCK_PATH)
|
||||
|
||||
try:
|
||||
process_identifier = int(process_identifier_file.read_text().strip())
|
||||
|
|
@ -319,8 +322,9 @@ class ConnectionController:
|
|||
except psutil.NoSuchProcess:
|
||||
pass
|
||||
|
||||
process_identifier_file.unlink(missing_ok=True)
|
||||
control_socket_file.unlink(missing_ok=True)
|
||||
process_identifier_file.unlink(missing_ok=True)
|
||||
instance_lock_file.unlink(missing_ok=True)
|
||||
|
||||
@staticmethod
|
||||
def establish_wireguard_session_connection(profile: SessionProfile, session_directory: str, port_number: int):
|
||||
|
|
|
|||
Loading…
Reference in a new issue