catch and log when cannot reach non-managed tor
parent
8d54519771
commit
39650a4ca0
|
@ -2,9 +2,13 @@
|
|||
|
||||
Create an ephemeral onion service
|
||||
"""
|
||||
import stem
|
||||
|
||||
from .torcontroller import get_controller
|
||||
|
||||
from filepaths import ephemeral_services_file
|
||||
|
||||
import logger
|
||||
"""
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@ -22,7 +26,11 @@ from filepaths import ephemeral_services_file
|
|||
|
||||
|
||||
def create_onion_service(port=80, record_to_service_removal_file=True):
|
||||
controller = get_controller()
|
||||
try:
|
||||
controller = get_controller()
|
||||
except stem.SocketError:
|
||||
logger.error("Could not connect to Tor control")
|
||||
raise
|
||||
hs = controller.create_ephemeral_hidden_service(
|
||||
{80: port},
|
||||
key_type='NEW',
|
||||
|
|
|
@ -8,6 +8,7 @@ import platform
|
|||
from threading import Thread
|
||||
|
||||
from stem.connection import IncorrectPassword
|
||||
import stem
|
||||
import toomanyobjs
|
||||
import filenuke
|
||||
from deadsimplekv import DeadSimpleKV
|
||||
|
@ -73,9 +74,11 @@ def _show_info_messages():
|
|||
(logger.colors.underline +
|
||||
getourkeypair.get_keypair()[0][:52]))
|
||||
|
||||
def _setup_online_mode(use_existing_tor: bool,
|
||||
net: NetController,
|
||||
security_level: int):
|
||||
|
||||
def _setup_online_mode(
|
||||
use_existing_tor: bool,
|
||||
net: NetController,
|
||||
security_level: int):
|
||||
if config.get('transports.tor', True):
|
||||
# If we are using tor, check if we are using an existing tor instance
|
||||
# if we are, we need to create an onion service on it and set attrs on our NetController
|
||||
|
@ -89,6 +92,12 @@ def _setup_online_mode(use_existing_tor: bool,
|
|||
try:
|
||||
net.myID = create_onion_service(
|
||||
port=net.apiServerIP + ':' + str(net.hsPort))[0]
|
||||
except stem.SocketError:
|
||||
logger.error(
|
||||
"Could not connect to existing Tor service", terminal=True)
|
||||
localcommand.local_command('shutdown')
|
||||
cleanup.delete_run_files()
|
||||
sys.exit(1)
|
||||
except IncorrectPassword:
|
||||
# Exit if we cannot connect to the existing Tor instance
|
||||
logger.error('Invalid Tor control password', terminal=True)
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
"disk": 1073741824
|
||||
},
|
||||
"general": {
|
||||
"allow_public_api_dns_rebinding": false,
|
||||
"announce_node": true,
|
||||
"dev_mode": false,
|
||||
"display_header": true,
|
||||
|
|
Loading…
Reference in New Issue