mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-11-29 08:25:10 +00:00
tor: Fix problems with running a relay
This is a fix for regression introduced by
ebe6a0ed02. I have incorrectly assumed that
providing only IPv6 ORPort is sufficient to listen on IPv4 and IPv6. As a
result, Tor does not run when relay is enabled. Fix this by adding ORPorts for
both IPv6 and IPv4.
Tests performed:
- Tor shows as running after enabling relay functionality.
- Adding single or multiple ORPort values in the configuration file leads to
actions/tor get-status reporting that relay is enabled.
- Functional tests for Tor run properly.
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
1 parent
a4dab3cc36
commit
8cb5716f76
2 files changed
+8
-6
No files matched your search
+6
-4
@@ -65,7 +65,7 @@ def parse_arguments():
|
||||
|
||||
def subcommand_setup(arguments):
|
||||
"""Setup Tor configuration after installing it."""
|
||||
if arguments.old_version and arguments.old_version <= 3:
|
||||
if arguments.old_version and arguments.old_version <= 4:
|
||||
_upgrade_orport_value()
|
||||
return
|
||||
|
||||
@@ -148,7 +148,8 @@ def _upgrade_orport_value():
|
||||
aug = augeas_load()
|
||||
|
||||
if _is_relay_enabled(aug):
|
||||
aug.set(TOR_CONFIG + '/ORPort', '[::]:9001')
|
||||
aug.set(TOR_CONFIG + '/ORPort[1]', '9001')
|
||||
aug.set(TOR_CONFIG + '/ORPort[2]', '[::]:9001')
|
||||
|
||||
aug.save()
|
||||
|
||||
@@ -241,7 +242,7 @@ def _get_upstream_bridges(aug):
|
||||
|
||||
def _is_relay_enabled(aug):
|
||||
"""Return whether a relay is enabled."""
|
||||
orport = aug.get(TOR_CONFIG + '/ORPort')
|
||||
orport = aug.get(TOR_CONFIG + '/ORPort[1]')
|
||||
return bool(orport) and orport != '0'
|
||||
|
||||
|
||||
@@ -390,7 +391,8 @@ def _enable_relay(relay=None, bridge=None, aug=None):
|
||||
use_upstream_bridges = _are_upstream_bridges_enabled(aug)
|
||||
|
||||
if relay == 'enable' and not use_upstream_bridges:
|
||||
aug.set(TOR_CONFIG + '/ORPort', '[::]:9001')
|
||||
aug.set(TOR_CONFIG + '/ORPort[1]', '9001')
|
||||
aug.set(TOR_CONFIG + '/ORPort[2]', '[::]:9001')
|
||||
elif relay == 'disable':
|
||||
aug.remove(TOR_CONFIG + '/ORPort')
|
||||
|
||||
|
||||
Reference in new issue
Block a user