tor: Use fixed 9001 port for relaying

When ORPort is set to 'auto', Tor automatically allocates a port for it. During
it's first run, we able to extract the port number and open the firewall port.
However, unlike for pluggable transports, Tor does not seem to store this port
for future reuse in the state file. It hence opens a new port every time it is
started. This leads to a new port being assigned on next Tor startup and leads
to relay functionality not being reachable from outside.

According to the documentation, only possible values for ORPort are a fixed
number or 0 (disable) or auto (current behavior). Choose 9001 as this is the
commonly used port number for ORPort. The recommended port number of 443 is not
possible in FreedomBox due it is use for other purposes.

Closes: #1495.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Sunil Mohan Adapa authored and James Valleroy committed 2019-02-18 07:13:19 -05:00
1 parent 595997ff7c
commit df76e6afa4
2 files changed
+76 -20

No files matched your search

+13 -6
View File
@@ -31,7 +31,7 @@ from plinth.signals import domain_added, domain_removed
from . import utils
from .manifest import backup, clients
version = 2
version = 3
depends = ['names']
@@ -106,9 +106,12 @@ def init():
def setup(helper, old_version=None):
"""Install and configure the module."""
helper.install(managed_packages)
helper.call('post', actions.superuser_run, 'tor', ['setup'])
helper.call('post', actions.superuser_run, 'tor',
['configure', '--apt-transport-tor', 'enable'])
helper.call(
'post', actions.superuser_run, 'tor',
['setup', '--old-version', str(old_version)])
if not old_version:
helper.call('post', actions.superuser_run, 'tor',
['configure', '--apt-transport-tor', 'enable'])
global socks_service
if socks_service is None:
@@ -116,7 +119,9 @@ def setup(helper, old_version=None):
'tor-socks', _('Tor Anonymity Network'), ports=['tor-socks'],
is_external=False, is_enabled=utils.is_enabled,
is_running=utils.is_running)
helper.call('post', socks_service.notify_enabled, None, True)
if not old_version:
helper.call('post', socks_service.notify_enabled, None, True)
global bridge_service
if bridge_service is None:
@@ -124,7 +129,9 @@ def setup(helper, old_version=None):
'tor-bridge', _('Tor Bridge Relay'),
ports=['tor-orport', 'tor-obfs3', 'tor-obfs4'], is_external=True,
is_enabled=utils.is_enabled, is_running=utils.is_running)
helper.call('post', bridge_service.notify_enabled, None, True)
if not old_version:
helper.call('post', bridge_service.notify_enabled, None, True)
helper.call('post', update_hidden_service_domain)