nbenedek 863afa34ce
tor: Add onion location to apache
- When hidden service is enabled create and enable an apache site with the
proper configurations. This will let visitors using the Tor browser that a
hidden version of the website is available.

- Disable apache site when hidden service is disabled

- Create a backup of the apache site

- Hidden service won't be advertised when the user visits mediawiki, wordpress
or tt-rss. These sites don't work (well) with a hidden service when a normal
domain is already set up.

Tests:

- Functional tests pass.

- With fresh install of Tor app, onion location header apache configuration is
enabled and header is served in HTTP requests.

- When Onion services are enabled/disabled, header is enabled/disabled due to
webserver configuration changes.

- When Tor app is enabled/disabled, header is enabled/disabled due to webserver
configuration being enabled/disabled.

- When Tor app is upgraded from earlier version while app is enabled, onion
service is enabled, Tor app remains enabled. Onion location is enabled.

- FAILED: When Tor app is upgraded from earlier version while app is enabled,
onion service is disabled, Tor app remains enabled. Onion location is disabled.

- FAILED: When Tor app is upgraded from earlier version while app is disabled,
onion service is enabled, Tor app remains disabled. Onion location is disabled.

- FAILED: When Tor app is upgraded from earlier version while app is disabled,
onion service is disabled, Tor app remains disabled. Onion location is disabled.

Signed-off-by: nbenedek <contact@nbenedek.me>
[sunil: Ensure that enabling/disabling app enables/disables onion location]
[sunil: Ensure that upgrading from old version does not enable the app]
[sunil: Ensure that upgrading from old version enables/disables onion location]
[sunil: Apache file should be a 'config' and not 'site']
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2023-01-02 22:11:36 -05:00

55 lines
1.3 KiB
Python

# SPDX-License-Identifier: AGPL-3.0-or-later
from django.utils.translation import gettext_lazy as _
from plinth.clients import store_url
from . import privileged
_orbot_package_id = 'org.torproject.android'
_tor_browser_download_url = \
'https://www.torproject.org/download/download-easy.html'
clients = [{
'name':
_('Tor Browser'),
'platforms': [{
'type': 'download',
'os': 'windows',
'url': _tor_browser_download_url,
}, {
'type': 'download',
'os': 'gnu-linux',
'url': _tor_browser_download_url,
}, {
'type': 'download',
'os': 'macos',
'url': _tor_browser_download_url,
}]
}, {
'name':
_('Orbot: Proxy with Tor'),
'platforms': [{
'type': 'store',
'os': 'android',
'store_name': 'google-play',
'url': store_url('google-play', _orbot_package_id)
}, {
'type': 'store',
'os': 'android',
'store_name': 'f-droid',
'url': store_url('f-droid', _orbot_package_id)
}]
}]
backup = {
'config': {
'directories': ['/etc/tor/'],
'files': [str(privileged.TOR_APACHE_SITE)]
},
'secrets': {
'directories': ['/var/lib/tor/', '/var/lib/tor-instances/']
},
'services': ['tor@plinth']
}