From 567af997d7247cdc2516a3a0a4d8385dc393287d Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Sun, 2 Feb 2020 00:55:39 -0600 Subject: [PATCH] Added dev config scripts --- scripts/disable-dev-config.py | 19 +++++++++++++++++++ scripts/enable-dev-config.py | 20 ++++++++++++++++++++ src/onionrcommands/daemonlaunch/__init__.py | 12 ++++++++++-- 3 files changed, 49 insertions(+), 2 deletions(-) create mode 100755 scripts/disable-dev-config.py create mode 100755 scripts/enable-dev-config.py diff --git a/scripts/disable-dev-config.py b/scripts/disable-dev-config.py new file mode 100755 index 00000000..ff337f09 --- /dev/null +++ b/scripts/disable-dev-config.py @@ -0,0 +1,19 @@ +#!/usr/bin/env python3 + +"""Enable dev default config""" + +import json + +conf = json.load(open('static-data/default_config.json', 'r')) + +conf['tor']['use_existing_tor'] = False +conf['tor']['existing_control_port'] = 0 +conf['tor']['existing_control_password'] = "" +conf['tor']['existing_socks_port'] = 0 + +conf['general']['dev_mode'] = False +conf['general']['insert_deniable_blocks'] = True +conf['general']['random_bind_ip'] = True + +json.dump(conf, open('static-data/default_config.json', 'w'), sort_keys=True, indent=4) + diff --git a/scripts/enable-dev-config.py b/scripts/enable-dev-config.py new file mode 100755 index 00000000..a25e61a4 --- /dev/null +++ b/scripts/enable-dev-config.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python3 + +"""Enable dev default config""" + +import json + +conf = json.load(open('static-data/default_config.json', 'r')) + +if input("Reuse Tor? y/n:").lower() == 'y': + conf['tor']['use_existing_tor'] = True + conf['tor']['existing_control_port'] = int(input("Enter existing control port:")) + conf['tor']['existing_control_password'] = input("Tor pass:") + conf['tor']['existing_socks_port'] = int(input("Existing socks port:")) + +conf['general']['dev_mode'] = True +conf['general']['insert_deniable_blocks'] = False +conf['general']['general.random_bind_ip'] = False + +json.dump(conf, open('static-data/default_config.json', 'w'), sort_keys=True, indent=4) + diff --git a/src/onionrcommands/daemonlaunch/__init__.py b/src/onionrcommands/daemonlaunch/__init__.py index 73c37f88..1a34cac5 100755 --- a/src/onionrcommands/daemonlaunch/__init__.py +++ b/src/onionrcommands/daemonlaunch/__init__.py @@ -9,6 +9,7 @@ import sqlite3 from threading import Thread from gevent import time from gevent import spawn +from stem.connection import IncorrectPassword import toomanyobjs @@ -114,8 +115,15 @@ def daemon(): if use_existing_tor: net.socksPort = config.get('tor.existing_socks_port') - net.myID = create_onion_service( - port=net.apiServerIP + ':' + str(net.hsPort))[0] + try: + net.myID = create_onion_service( + port=net.apiServerIP + ':' + str(net.hsPort))[0] + except IncorrectPassword: + logger.error('Invalid Tor control password', terminal=True) + localcommand.local_command('shutdown') + cleanup.delete_run_files() + sys.exit(1) + if not net.myID.endswith('.onion'): net.myID += '.onion' with open(filepaths.tor_hs_address_file, 'w') as tor_file: