Show info about installing Tor if it is not already installed.

This commit is contained in:
James Valleroy 2014-11-10 22:17:49 -05:00
parent 28cc7f14c7
commit a7afba8583
2 changed files with 26 additions and 10 deletions

View File

@ -22,6 +22,8 @@
{% block main_block %} {% block main_block %}
{% if is_installed %}
<h3>Status</h3> <h3>Status</h3>
<br style='clear:both'> <br style='clear:both'>
@ -33,7 +35,7 @@
<br style='clear:both'> <br style='clear:both'>
<p><h3>Hidden Service</h3> <p><h3>Hidden Service</h3>
A hidden service will allow your FreedomBox to provide selected A hidden service will allow your {{ cfg.box_name }} to provide selected
services (such as OwnCloud or Chat) without revealing its location. services (such as OwnCloud or Chat) without revealing its location.
Here is the current configuration: Here is the current configuration:
<ul> <ul>
@ -52,8 +54,8 @@ Here is the current configuration:
</p> </p>
<p><h3>Bridge</h3> <p><h3>Bridge</h3>
Your FreedomBox is configured as a Tor bridge with obfsproxy, so it Your {{ cfg.box_name }} is configured as a Tor bridge with obfsproxy, so it
can help circumvent censorship. If your FreedomBox is behind a router can help circumvent censorship. If your {{ cfg.box_name }} is behind a router
or firewall, you should make sure the following ports are open, and or firewall, you should make sure the following ports are open, and
port-forwarded, if necessary:</p> port-forwarded, if necessary:</p>
@ -68,9 +70,18 @@ port-forwarded, if necessary:</p>
<br style='clear:both'> <br style='clear:both'>
<p><h3>SOCKS</h3> <p><h3>SOCKS</h3>
A Tor SOCKS port is available on your FreedomBox on TCP port A Tor SOCKS port is available on your {{ cfg.box_name }} on TCP port
9050.</p> 9050.</p>
{% else %}
<p>Tor is not installed, please install it. Tor comes pre-installed
with {{ cfg.box_name }}. On any Debian-based system (such as
{{ cfg.box_name }}) you may install it using the command
'aptitude install tor'.</p>
{% endif %}
{% endblock %} {% endblock %}
{% block sidebar_right_block %} {% block sidebar_right_block %}
@ -80,11 +91,11 @@ A Tor SOCKS port is available on your FreedomBox on TCP port
<h3>Tor</h3> <h3>Tor</h3>
<p>Tor is an anonymous communication system. You can learn more about <p>Tor is an anonymous communication system. You can learn more about
it from the <a href="https://www.torproject.org/">Tor Project</a> it from the <a href="https://www.torproject.org/">Tor Project</a>
website. For best protection when web surfing, the Tor Project website. For best protection when web surfing, the Tor Project
recommends that you use recommends that you use the
the <a href="https://www.torproject.org/download/download-easy.html.en">Tor <a href="https://www.torproject.org/download/download-easy.html.en">
Browser Bundle</a>.</p> Tor Browser</a>.</p>
</div> </div>

View File

@ -61,6 +61,7 @@ def index(request):
return TemplateResponse(request, 'tor.html', return TemplateResponse(request, 'tor.html',
{'title': _('Tor Control Panel'), {'title': _('Tor Control Panel'),
'is_installed': status['is_installed'],
'is_running': status['is_running'], 'is_running': status['is_running'],
'tor_ports': status['ports'], 'tor_ports': status['ports'],
'tor_hs_enabled': status['hs_enabled'], 'tor_hs_enabled': status['hs_enabled'],
@ -71,6 +72,9 @@ def index(request):
def get_status(): def get_status():
"""Return the current status""" """Return the current status"""
is_installed = actions.superuser_run(
'tor',
['get-installed']).strip() == 'installed'
is_running = actions.superuser_run('tor', ['is-running']).strip() == 'yes' is_running = actions.superuser_run('tor', ['is-running']).strip() == 'yes'
output = actions.superuser_run('tor-get-ports') output = actions.superuser_run('tor-get-ports')
@ -99,7 +103,8 @@ def get_status():
hs_hostname = hs_info[0] hs_hostname = hs_info[0]
hs_ports = hs_info[1] hs_ports = hs_info[1]
return {'is_running': is_running, return {'is_installed': is_installed,
'is_running': is_running,
'ports': ports, 'ports': ports,
'hs_enabled': hs_enabled, 'hs_enabled': hs_enabled,
'hs_hostname': hs_hostname, 'hs_hostname': hs_hostname,