diff --git a/src/communicator/daemoneventhooks/__init__.py b/src/communicator/daemoneventhooks/__init__.py index 16050202..f43ac54f 100644 --- a/src/communicator/daemoneventhooks/__init__.py +++ b/src/communicator/daemoneventhooks/__init__.py @@ -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) diff --git a/src/communicatorutils/netcheck.py b/src/communicatorutils/netcheck.py index b4a5ddf6..df3d8c0e 100755 --- a/src/communicatorutils/netcheck.py +++ b/src/communicatorutils/netcheck.py @@ -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: diff --git a/src/communicatorutils/restarttor.py b/src/communicatorutils/restarttor.py index 9ffde83d..35388d05 100644 --- a/src/communicatorutils/restarttor.py +++ b/src/communicatorutils/restarttor.py @@ -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() diff --git a/src/netcontroller/torcontrol/rebuildtor.py b/src/netcontroller/torcontrol/rebuildtor.py index 8e366ae0..2367530a 100644 --- a/src/netcontroller/torcontrol/rebuildtor.py +++ b/src/netcontroller/torcontrol/rebuildtor.py @@ -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." diff --git a/src/onionrcommands/parser/arguments.py b/src/onionrcommands/parser/arguments.py index eba3add1..a0126fb0 100644 --- a/src/onionrcommands/parser/arguments.py +++ b/src/onionrcommands/parser/arguments.py @@ -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, diff --git a/src/onionrcommands/togglebootstrap.py b/src/onionrcommands/togglebootstrap.py index 0e25bf43..3970f962 100644 --- a/src/onionrcommands/togglebootstrap.py +++ b/src/onionrcommands/togglebootstrap.py @@ -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) diff --git a/src/onionrstatistics/transports/tor/__init__.py b/src/onionrstatistics/transports/tor/__init__.py index cb98f91a..76446508 100644 --- a/src/onionrstatistics/transports/tor/__init__.py +++ b/src/onionrstatistics/transports/tor/__init__.py @@ -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(): diff --git a/static-data/www/private/index.html b/static-data/www/private/index.html index 0cb16ad8..031c893b 100755 --- a/static-data/www/private/index.html +++ b/static-data/www/private/index.html @@ -12,6 +12,7 @@ + @@ -274,6 +275,12 @@
Unable to get nodes
+ Restart Tor +
+