tor: Listen on IPv6 for OrPort

- Fix regex for reading OrPort value from command port communication.

- Setup all new configurations for listening on IPv6 for OrPort.

- Upgrade existing configuration for listening on IPv6 for OrPort. Increment app
  version number force run setup again.

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-11-15 20:14:49 -05:00
1 parent ca9047104a
commit ebe6a0ed02
2 files changed
+5 -5

No files matched your search

+4 -4
View File
@@ -80,7 +80,7 @@ def parse_arguments():
def subcommand_setup(arguments):
"""Setup Tor configuration after installing it."""
if arguments.old_version and arguments.old_version <= 2:
if arguments.old_version and arguments.old_version <= 3:
_upgrade_orport_value()
return
@@ -163,7 +163,7 @@ def _upgrade_orport_value():
aug = augeas_load()
if _is_relay_enabled(aug):
aug.set(TOR_CONFIG + '/ORPort', '9001')
aug.set(TOR_CONFIG + '/ORPort', '[::]:9001')
aug.save()
@@ -304,7 +304,7 @@ QUIT
tor_socket.close()
line = response.split(b'\r\n')[1].decode()
matches = re.match(r'.*="[^:]+:(\d+)"', line)
matches = re.match(r'.*=".+:(\d+)"', line)
return matches.group(1)
@@ -405,7 +405,7 @@ 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', '[::]:9001')
elif relay == 'disable':
aug.remove(TOR_CONFIG + '/ORPort')