diff --git a/src/netcontroller/torcontrol/onionservicecreator.py b/src/netcontroller/torcontrol/onionservicecreator.py index ddb814bd..f8600499 100644 --- a/src/netcontroller/torcontrol/onionservicecreator.py +++ b/src/netcontroller/torcontrol/onionservicecreator.py @@ -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', diff --git a/src/onionrcommands/daemonlaunch/__init__.py b/src/onionrcommands/daemonlaunch/__init__.py index 29a1321e..c3b5a89d 100755 --- a/src/onionrcommands/daemonlaunch/__init__.py +++ b/src/onionrcommands/daemonlaunch/__init__.py @@ -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) diff --git a/static-data/default_config.json b/static-data/default_config.json index 1aba4f7c..4846991a 100755 --- a/static-data/default_config.json +++ b/static-data/default_config.json @@ -6,6 +6,7 @@ "disk": 1073741824 }, "general": { + "allow_public_api_dns_rebinding": false, "announce_node": true, "dev_mode": false, "display_header": true,