mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-07-08 11:40:25 +00:00
tor: Minor refactor to remove code the check for need to restart
- Any change to the remaining form fields now certainly requires restart of the Tor daemon. Tests: - When no changes are done to the form, tor daemon is not restarted. - When changes are done to the form, tor daemon is restarted. But only when app is enabled. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
b7613d6e5a
commit
e9056afe00
@ -79,38 +79,31 @@ def _apply_changes(old_status, new_status):
|
||||
|
||||
def __apply_changes(old_status, new_status):
|
||||
"""Apply the changes."""
|
||||
needs_restart = False
|
||||
arguments = {}
|
||||
|
||||
app = app_module.App.get('tor')
|
||||
is_enabled = app.is_enabled()
|
||||
|
||||
if old_status['relay_enabled'] != new_status['relay_enabled']:
|
||||
arguments['relay'] = new_status['relay_enabled']
|
||||
needs_restart = True
|
||||
|
||||
if old_status['bridge_relay_enabled'] != \
|
||||
new_status['bridge_relay_enabled']:
|
||||
arguments['bridge_relay'] = new_status['bridge_relay_enabled']
|
||||
needs_restart = True
|
||||
|
||||
if old_status['hs_enabled'] != new_status['hs_enabled']:
|
||||
arguments['hidden_service'] = new_status['hs_enabled']
|
||||
needs_restart = True
|
||||
|
||||
if old_status['use_upstream_bridges'] != \
|
||||
new_status['use_upstream_bridges']:
|
||||
arguments['use_upstream_bridges'] = new_status['use_upstream_bridges']
|
||||
needs_restart = True
|
||||
|
||||
if old_status['upstream_bridges'] != new_status['upstream_bridges']:
|
||||
arguments['upstream_bridges'] = new_status['upstream_bridges']
|
||||
needs_restart = True
|
||||
|
||||
if arguments:
|
||||
privileged.configure(**arguments)
|
||||
|
||||
if needs_restart and is_enabled:
|
||||
privileged.restart()
|
||||
status = tor_utils.get_status()
|
||||
tor.update_hidden_service_domain(status)
|
||||
if is_enabled:
|
||||
privileged.restart()
|
||||
status = tor_utils.get_status()
|
||||
tor.update_hidden_service_domain(status)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user