Added tor restart button to index and tor restart command. Enabled tor restart daemon event
This commit is contained in:
parent
b4d80da3ff
commit
1f067f614a
@ -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)
|
||||
|
@ -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:
|
||||
|
@ -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()
|
||||
|
@ -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."
|
||||
|
@ -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,
|
||||
|
@ -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)
|
||||
|
@ -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():
|
||||
|
@ -12,6 +12,7 @@
|
||||
<link rel="stylesheet" href="/shared/fontawesome-free-5.10.2/css/all.min.css">
|
||||
<link rel="stylesheet" href="/shared/main/PNotifyBrightTheme.css">
|
||||
<link rel="stylesheet" href="/shared/bulma-quickview.min.css">
|
||||
<link rel="stylesheet" href="/shared/bulma-tooltip.min.css">
|
||||
<link rel="stylesheet" href="/gettheme">
|
||||
<link rel="stylesheet" href="/shared/sidebar/sidebar.css">
|
||||
<script defer src="/shared/node_modules/pnotify/dist/iife/PNotify.js"></script>
|
||||
@ -274,6 +275,12 @@
|
||||
<pre id="connectedNodes">Unable to get nodes</pre>
|
||||
</div>
|
||||
<br>
|
||||
<div class="field">
|
||||
<p class="control">
|
||||
<a class="button is-light restartTor" data-tooltip="Use if there have been no incoming or outgoing connections in a long time">Restart Tor</a>
|
||||
</p>
|
||||
</div>
|
||||
<br>
|
||||
<h4>Blocks</h4>
|
||||
<div class="columns">
|
||||
<div class="column">
|
||||
|
@ -20,6 +20,46 @@
|
||||
shutdownBtn = document.getElementById('shutdownNode')
|
||||
restartBtn = document.getElementById('restartNode')
|
||||
|
||||
|
||||
let restartTorBtnControl = function(){
|
||||
if (typeof config == "undefined" || typeof config.tor == "undefined"){
|
||||
setTimeout(function(){restartTorBtnControl()}, 10)
|
||||
return
|
||||
}
|
||||
var restartTor = document.getElementsByClassName('restartTor')[0]
|
||||
|
||||
if (config.tor.use_existing_tor){
|
||||
restartTor.classList.add('is-hidden')
|
||||
return
|
||||
}
|
||||
|
||||
restartTor.onclick = function(){
|
||||
if (restartTor.disabled){
|
||||
console.debug("Tor still restarting (or restart_tor event failed)")
|
||||
return
|
||||
}
|
||||
restartTor.disabled = true
|
||||
PNotify.success({
|
||||
text: 'Initializing Tor restart...'
|
||||
})
|
||||
fetch('/daemon-event/restart_tor', {
|
||||
method: 'POST',
|
||||
body: {},
|
||||
headers: {
|
||||
"content-type": "application/json",
|
||||
"token": webpass
|
||||
}})
|
||||
.then((resp) => resp.text())
|
||||
.then(function(data) {
|
||||
PNotify.success({
|
||||
text: 'Tor restarting...'
|
||||
})
|
||||
restartTor.disabled = false
|
||||
})
|
||||
}
|
||||
}
|
||||
restartTorBtnControl()
|
||||
|
||||
shutdownBtn.onclick = function(){
|
||||
if (! nowebpass){
|
||||
if (confirm("Really shutdown Onionr?")){
|
||||
|
Loading…
Reference in New Issue
Block a user