diff --git a/plinth/modules/tor/__init__.py b/plinth/modules/tor/__init__.py index 6933e9348..e12773198 100644 --- a/plinth/modules/tor/__init__.py +++ b/plinth/modules/tor/__init__.py @@ -20,7 +20,7 @@ Plinth module to configure Tor. """ import augeas -from django.utils.translation import ugettext as _ +from django.utils.translation import ugettext_lazy as _ import glob import itertools @@ -32,8 +32,21 @@ from plinth.modules.names import SERVICES from plinth.signals import domain_added +version = 1 + depends = ['apps', 'names'] +title = _('Anonymity Network (Tor)') + +description = [ + _('Tor is an anonymous communication system. You can learn more ' + 'about it from the Tor ' + 'Project website. For best protection when web surfing, the ' + 'Tor Project recommends that you use the ' + '' + 'Tor Browser.') +] + socks_service = None bridge_service = None @@ -45,8 +58,7 @@ APT_TOR_PREFIX = 'tor+' def init(): """Initialize the module.""" menu = cfg.main_menu.get('apps:index') - menu.add_urlname(_('Anonymity Network (Tor)'), 'glyphicon-eye-close', - 'tor:index', 100) + menu.add_urlname(title, 'glyphicon-eye-close', 'tor:index', 100) global socks_service socks_service = service_module.Service( @@ -77,6 +89,17 @@ def init(): services=hs_services) +def setup(helper, old_version=None): + """Install and configure the module.""" + helper.install(['tor', 'tor-geoipdb', 'torsocks', 'obfs4proxy', + 'apt-transport-tor']) + helper.call('post', actions.superuser_run, 'tor', ['setup']) + helper.call('post', actions.superuser_run, 'tor', + ['configure', '--apt-transport-tor', 'enable']) + helper.call('post', socks_service.notify_enabled, None, True) + helper.call('post', bridge_service.notify_enabled, None, True) + + def is_enabled(): """Return whether the module is enabled.""" return action_utils.service_is_enabled('tor') diff --git a/plinth/modules/tor/templates/tor.html b/plinth/modules/tor/templates/tor.html index 2b1b0f07e..9b6db3ed5 100644 --- a/plinth/modules/tor/templates/tor.html +++ b/plinth/modules/tor/templates/tor.html @@ -1,4 +1,4 @@ -{% extends "base.html" %} +{% extends "app.html" %} {% comment %} # # This file is part of Plinth. @@ -30,20 +30,7 @@ {% endblock %} -{% block content %} - -

{% trans "Anonymity Network (Tor)" %}

- -

- {% blocktrans trimmed %} - Tor is an anonymous communication system. You can learn more - about it from the Tor - Project website. For best protection when web surfing, the - Tor Project recommends that you use the - - Tor Browser. - {% endblocktrans %} -

+{% block configuration %}

{% trans "Status" %}

diff --git a/plinth/modules/tor/views.py b/plinth/modules/tor/views.py index 120e42133..58e513a1f 100644 --- a/plinth/modules/tor/views.py +++ b/plinth/modules/tor/views.py @@ -25,7 +25,6 @@ from django.utils.translation import ugettext_lazy as _ from .forms import TorForm from plinth import actions -from plinth import package from plinth.errors import ActionError from plinth.modules import tor from plinth.modules.names import SERVICES @@ -34,18 +33,6 @@ from plinth.signals import domain_added, domain_removed config_process = None -def on_install(): - """Setup Tor configuration as soon as it is installed.""" - actions.superuser_run('tor', ['setup']) - actions.superuser_run('tor', - ['configure', '--apt-transport-tor', 'enable']) - tor.socks_service.notify_enabled(None, True) - tor.bridge_service.notify_enabled(None, True) - - -@package.required(['tor', 'tor-geoipdb', 'torsocks', 'obfs4proxy', - 'apt-transport-tor'], - on_install=on_install) def index(request): """Serve configuration page.""" if config_process: @@ -65,7 +52,8 @@ def index(request): form = TorForm(initial=status, prefix='tor') return TemplateResponse(request, 'tor.html', - {'title': _('Tor Control Panel'), + {'title': tor.title, + 'description': tor.description, 'status': status, 'config_running': bool(config_process), 'form': form})