{% extends "base.html" %}
{% comment %}
#
# This file is part of Plinth.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
{% endcomment %}

{% load bootstrap %}
{% load i18n %}

{% 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>

  <h3>{% trans "Status" %}</h3>

  <p class="running-status-parent">
    {% if status.is_running %}
      <span class="running-status active"></span>
      {% trans "Tor is running" %}
    {% else %}
      <span class="running-status inactive"></span>
      {% trans "Tor is not running" %}
    {% endif %}
  </p>

  {% include "diagnostics_button.html" with module="tor" %}

  {% if status.hs_enabled %}
    <div class="row">
      <div class="col-sm-3">
        <table class="table table-bordered table-condensed table-striped">
          <thead>
            <tr>
              <th>{% trans "Hidden Service" %}</th>
              <th>{% trans "Port" %}</th>
            </tr>
          </thead>
          <tbody>
            <tr>
              <td>{{ status.hs_hostname }}</td>
              <td>{{ status.hs_ports }}</td>
            </tr>
          </tbody>
        </table>
      </div>
    </div>
  {% endif %}

  <h3>{% trans "Configuration" %}</h3>

  <form class="form" method="post">
    {% csrf_token %}

    {{ form|bootstrap }}

    <input type="submit" class="btn btn-primary btn-md"
           value="{% trans "Update setup" %}"/>
  </form>

  <h3>{% trans "Bridge" %}</h3>

  <p>
    {% blocktrans trimmed with box_name=cfg.box_name %}
      Your {{ box_name }} is configured as a Tor bridge with obfsproxy,
      so it can help circumvent censorship. If your {{ box_name }} is
      behind a router or firewall, you should make sure the following
      ports are open, and port-forwarded, if necessary:
    {% endblocktrans %}
  </p>

  <div class="row">
    <div class="col-sm-3">
      <table class="table table-bordered table-condensed table-striped">
        <thead>
          <tr>
            <th>{% trans "Service" %}</th>
            <th>{% trans "Port" %}</th>
          </tr>
        </thead>
        <tbody>
          {% for name, port in status.ports.items %}
            <tr>
              <td>{{ name }}</td>
              <td>{{ port }}</td>
            </tr>
          {% endfor %}
        </tbody>
      </table>
    </div>
  </div>

  <h3>{% trans "SOCKS" %}</h3>

  <p>
    {% blocktrans trimmed with box_name=cfg.box_name %}
      A Tor SOCKS port is available on your {{ box_name }} on TCP port
      9050.
    {% endblocktrans %}
  </p>

{% endblock %}
