mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-28 08:03:36 +00:00
tor: Use new setup mechanism
This commit is contained in:
parent
ecad252653
commit
ac558568ba
@ -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 <a href="https://www.torproject.org/">Tor '
|
||||
'Project</a> website. For best protection when web surfing, the '
|
||||
'Tor Project recommends that you use the '
|
||||
'<a href="https://www.torproject.org/download/download-easy.html.en">'
|
||||
'Tor Browser</a>.')
|
||||
]
|
||||
|
||||
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')
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
{% extends "base.html" %}
|
||||
{% extends "app.html" %}
|
||||
{% comment %}
|
||||
#
|
||||
# This file is part of Plinth.
|
||||
@ -30,20 +30,7 @@
|
||||
{% endblock %}
|
||||
|
||||
|
||||
{% block content %}
|
||||
|
||||
<h2>{% trans "Anonymity Network (Tor)" %}</h2>
|
||||
|
||||
<p>
|
||||
{% blocktrans trimmed %}
|
||||
Tor is an anonymous communication system. You can learn more
|
||||
about it from the <a href="https://www.torproject.org/">Tor
|
||||
Project</a> website. For best protection when web surfing, the
|
||||
Tor Project recommends that you use the
|
||||
<a href="https://www.torproject.org/download/download-easy.html.en">
|
||||
Tor Browser</a>.
|
||||
{% endblocktrans %}
|
||||
</p>
|
||||
{% block configuration %}
|
||||
|
||||
<h3>{% trans "Status" %}</h3>
|
||||
|
||||
|
||||
@ -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})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user