Added dev config scripts

This commit is contained in:
Kevin Froman 2020-02-02 00:55:39 -06:00
parent 88146a5690
commit 567af997d7
3 changed files with 49 additions and 2 deletions

19
scripts/disable-dev-config.py Executable file
View File

@ -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)

20
scripts/enable-dev-config.py Executable file
View File

@ -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)

View File

@ -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: