mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-21 07:55:00 +00:00
tor: Fix various issues related to plinth instance
- Remove extra newlines added to torrc. - Remove comments added in random places to torrc. - Enable tor instance during setup. - Fix restarts to use tor instance. - Revert change to augeas lens to attempt handling +. - Add support for hyphens in values to augeas lens. - Increment module version so setup can run again.
This commit is contained in:
parent
658e52f6cd
commit
85b87268b4
@ -14,6 +14,7 @@ All notable changes to this project will be documented in this file.
|
||||
- frontpage: Show app logos instead of generic icons.
|
||||
- Prevent anonymous users from accessing setup pages.
|
||||
- Firstboot, KVStore: merge old firstboot state fields.
|
||||
- tor: Use Plinth-specific instance instead of default.
|
||||
|
||||
## [0.12.0] - 2016-12-08
|
||||
### Added
|
||||
|
||||
17
actions/tor
17
actions/tor
@ -70,21 +70,24 @@ def parse_arguments():
|
||||
def subcommand_setup(_):
|
||||
"""Setup Tor configuration after installing it."""
|
||||
|
||||
# Disable default tor service. We will use tor@plinth instance
|
||||
# instead.
|
||||
_disable_apt_transport_tor()
|
||||
action_utils.service_disable('tor')
|
||||
|
||||
subprocess.run(['tor-instance-create', 'plinth'], check=True)
|
||||
|
||||
# Remove line starting with +SocksPort, since our augeas lens
|
||||
# doesn't handle it correctly.
|
||||
with open('/etc/tor/instances/plinth/torrc', 'r') as torrc:
|
||||
torrc_lines = torrc.readlines()
|
||||
with open('/etc/tor/instances/plinth/torrc', 'w') as torrc:
|
||||
for line in torrc_lines:
|
||||
if not line.startswith('+'):
|
||||
torrc.write(line + '\n')
|
||||
torrc.write(line)
|
||||
|
||||
aug = augeas_load()
|
||||
|
||||
aug.set(TOR_CONFIG + '/#comment[last() + 1]',
|
||||
'Run as non-exit bridge relay')
|
||||
aug.set(TOR_CONFIG + '/SocksPort[1]', '[::]:9050')
|
||||
aug.set(TOR_CONFIG + '/SocksPort[2]', '0.0.0.0:9050')
|
||||
aug.set(TOR_CONFIG + '/ControlPort', '9051')
|
||||
@ -92,7 +95,6 @@ def subcommand_setup(_):
|
||||
aug.set(TOR_CONFIG + '/ExitPolicy[1]', 'reject *:*')
|
||||
aug.set(TOR_CONFIG + '/ExitPolicy[2]', 'reject6 *:*')
|
||||
|
||||
aug.set(TOR_CONFIG + '/#comment[last() + 1]', 'Enable transparent proxy')
|
||||
aug.set(TOR_CONFIG + '/VirtualAddrNetworkIPv4', '10.192.0.0/10')
|
||||
aug.set(TOR_CONFIG + '/AutomapHostsOnResolve', '1')
|
||||
aug.set(TOR_CONFIG + '/TransPort[1]', '127.0.0.1:9040')
|
||||
@ -111,6 +113,7 @@ def subcommand_setup(_):
|
||||
|
||||
aug.save()
|
||||
|
||||
action_utils.service_enable('tor@plinth')
|
||||
action_utils.service_restart('tor@plinth')
|
||||
_update_ports()
|
||||
|
||||
@ -286,7 +289,7 @@ def _enable_relay(relay=None, bridge=None, restart=True, aug=None):
|
||||
|
||||
if restart:
|
||||
if is_enabled() and is_running():
|
||||
action_utils.service_restart('tor')
|
||||
action_utils.service_restart('tor@plinth')
|
||||
|
||||
|
||||
def _enable_hs(restart=True):
|
||||
@ -308,7 +311,7 @@ def _enable_hs(restart=True):
|
||||
|
||||
if restart:
|
||||
if is_enabled() and is_running():
|
||||
action_utils.service_restart('tor')
|
||||
action_utils.service_restart('tor@plinth')
|
||||
|
||||
# wait until hidden service information is available
|
||||
tries = 0
|
||||
@ -333,7 +336,7 @@ def _disable_hs(restart=True):
|
||||
|
||||
if restart:
|
||||
if is_enabled() and is_running():
|
||||
action_utils.service_restart('tor')
|
||||
action_utils.service_restart('tor@plinth')
|
||||
|
||||
|
||||
def _enable_apt_transport_tor():
|
||||
|
||||
@ -8,5 +8,4 @@ test Tor.lns get "SocksPort [::]:9050\n" = { "SocksPort" = "[::]:9050" }
|
||||
test Tor.lns get "ExitPolicy reject *:*\n" = { "ExitPolicy" = "reject *:*" }
|
||||
test Tor.lns get "VirtualAddrNetworkIPv4 10.192.0.0/10\n" = { "VirtualAddrNetworkIPv4" = "10.192.0.0/10" }
|
||||
test Tor.lns get "ServerTransportPlugin obfs3,obfs4 exec /usr/bin/obfs4proxy\n" = { "ServerTransportPlugin" = "obfs3,obfs4 exec /usr/bin/obfs4proxy" }
|
||||
test Tor.lns get "HiddenServiceDir /var/lib/tor/hidden_service/\n" = { "HiddenServiceDir" = "/var/lib/tor/hidden_service/" }
|
||||
test Tor.lns get "+SocksPort auto" = { "SocksPort" = "auto" }
|
||||
test Tor.lns get "HiddenServiceDir /var/lib/tor-instances/plinth/hidden_service/\n" = { "HiddenServiceDir" = "/var/lib/tor-instances/plinth/hidden_service/" }
|
||||
|
||||
@ -22,8 +22,8 @@ autoload xfm
|
||||
let eol = Util.eol
|
||||
|
||||
let ws = /[ \t]/
|
||||
let kc = /[A-Za-z0-9_.,:*+]/
|
||||
let vc = /[A-Za-z0-9_.,:*\/ ]/
|
||||
let kc = /[A-Za-z0-9_.,:*]/
|
||||
let vc = /[-A-Za-z0-9_.,:*\/ ]/
|
||||
let keyname = kc+
|
||||
let val = /[[\/]*/ . kc . (vc* . /[]]*/ . vc* . kc . /[\/]*/)?
|
||||
|
||||
|
||||
@ -32,7 +32,7 @@ from plinth.signals import domain_added, domain_removed
|
||||
from . import utils
|
||||
|
||||
|
||||
version = 1
|
||||
version = 2
|
||||
|
||||
depends = ['apps', 'names']
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user