Added tor restart button to index and tor restart command. Enabled tor restart daemon event

This commit is contained in:
Kevin Froman 2020-09-15 17:08:50 +00:00
parent b4d80da3ff
commit 1f067f614a
9 changed files with 63 additions and 6 deletions

View file

@ -67,14 +67,16 @@ def daemon_event_handlers(shared_state: 'TooMany'):
return "removed"
def restart_tor():
restarttor.restart(comm_inst)
restarttor.restart(shared_state)
kv.put('offlinePeers', [])
kv.put('onlinePeers', [])
def test_runtime():
Thread(target=comm_inst.shared_state.get_by_string(
"OnionrRunTestManager").run_tests).start()
events_api.register_listener(remove_from_insert_queue_wrapper)
events_api.register_listener(restart_tor)
events_api.register_listener(print_test)
events_api.register_listener(upload_event)
events_api.register_listener(test_runtime)

View file

@ -53,7 +53,7 @@ def net_check(comm_inst):
'the Internet, and is Tor working? ' +
'This is usually temporary, but bugs and censorship can cause this to persist, in which case you should report it to beardog [at] mailbox.org', # noqa
terminal=True)
restarttor.restart(comm_inst)
restarttor.restart(comm_inst.shared_state)
kv.put('offlinePeers', [])
kv.put('isOnline', False)
else:

View file

@ -21,8 +21,8 @@ import config
"""
def restart(comm_inst):
def restart(shared_state):
if not config.get('tor.use_existing_tor', False):
net = comm_inst.shared_state.get(netcontroller.NetController)
net = shared_state.get(netcontroller.NetController)
net.killTor()
net.startTor()

View file

@ -30,3 +30,6 @@ def rebuild():
is_json=True,
post_data={}
).get(10)
rebuild.onionr_help = "If Onionr is running and is managing its own Tor daemon, restart that daemon."

View file

@ -19,6 +19,7 @@ from .. import motdcreator # cmd to generate new Onionr MOTDs
from .. import sitecreator # cmd to create multi-page sites
from .. import togglebootstrap # cmd to toggle bootstrap file usage
from ..listsites import print_site_list # cmd to list list ids
from netcontroller.torcontrol.rebuildtor import rebuild as tor_restart
import onionrexceptions
from onionrutils import importnewblocks # func to import new blocks
@ -53,6 +54,7 @@ def get_arguments() -> dict:
('start', 'daemon'): daemonlaunch.start,
('stop', 'kill'): daemonlaunch.kill_daemon,
('restart',): restartonionr.restart,
('restart-tor', 'restarttor'): tor_restart,
('add-address', 'addaddress', 'addadder'): keyadders.add_address,
('openhome', 'gui', 'openweb',
'open-home', 'open-web'): openwebinterface.open_home,

View file

@ -24,7 +24,6 @@ import logger
def toggle_bootstrap_config():
"""Toggles the bootstrap configuration."""
print("test")
if config.get('general.use_bootstrap_list') is None:
logger.error('No general.bootstrap_list setting found')
sys.exit(3)

View file

@ -1,10 +1,11 @@
"""Onionr - Private P2P Communication.
tor stats info
"""
import ujson as json
from stem import CircStatus
import logger
from netcontroller.torcontrol.torcontroller import get_controller
"""
@ -37,6 +38,9 @@ class TorStats:
"""
if self.controller is None:
self.controller = get_controller()
if not self.controller.is_alive():
logger.info(f'{__name__} reconnecting to tor control')
self.controller = get_controller()
self.get_circuits()
json_serialized = {}
for circuit in self.circuits.keys():