onions: add onion service management

This commit is contained in:
Iain Learmonth 2022-05-04 15:36:36 +01:00
parent 9987c996c9
commit 8efb7d9186
11 changed files with 327 additions and 2 deletions

View file

@ -82,6 +82,12 @@
Origins
</a>
</li>
<li class="nav-item">
<a class="nav-link{% if section == "onion" %} active{% endif %}"
href="{{ url_for("portal.onion.onion_list") }}">
Onion Services
</a>
</li>
<li class="nav-item">
<a class="nav-link{% if section == "list" %} active{% endif %}"
href="{{ url_for("portal.view_mirror_lists") }}">

View file

@ -1,6 +1,7 @@
{% extends "base.html.j2" %}
{% from "tables.html.j2" import bridgeconfs_table, bridges_table,
groups_table, mirrorlists_table, origins_table, proxies_table %}
groups_table, mirrorlists_table, origins_table, origin_onion_table,
onions_table, proxies_table %}
{% block content %}
<h1 class="h2 mt-3">{{ title }}</h1>
@ -17,6 +18,12 @@
{{ groups_table(items) }}
{% elif item == "mirror list" %}
{{ mirrorlists_table(items) }}
{% elif item == "onion service" %}
{% if section == "onion" %}
{{ onions_table(items) }}
{% elif section == "origin" %}
{{ origin_onion_table(items) }}
{% endif %}
{% elif item == "origin" %}
{{ origins_table(items) }}
{% elif item == "proxy" %}

View file

@ -0,0 +1,16 @@
{% extends "base.html.j2" %}
{% from 'bootstrap5/form.html' import render_form %}
{% from "tables.html.j2" import proxies_table %}
{% block content %}
<h1 class="h2 mt-3">Onion Services</h1>
<h2 class="h3">
{{ onion.group.group_name }}: {{ onion.onion_name }}.onion
<a href="https://{{ onion.onion_name }}.onion/" class="btn btn-secondary btn-sm" target="_bypass"
rel="noopener noreferer">⎋</a>
</h2>
<div style="border: 1px solid #666;" class="p-3">
{{ render_form(form) }}
</div>
{% endblock %}

View file

@ -61,6 +61,7 @@
<th scope="col">Name</th>
<th scope="col">Description</th>
<th scope="col">Auto-rotation</th>
<th scope="col">Onion Service</th>
<th scope="col">Group</th>
<th scope="col">Actions</th>
</tr>
@ -76,6 +77,7 @@
</td>
<td>{{ origin.description }}</td>
<td>{% if origin.auto_rotation %}✅{% else %}❌{% endif %}</td>
<td>{% if origin.onion() %}✅{% else %}❌{% endif %}</td>
<td>
<a href="{{ url_for("portal.group.group_edit", group_id=origin.group.id) }}">{{ origin.group.group_name }}</a>
</td>
@ -91,6 +93,92 @@
</div>
{% endmacro %}
{% macro origin_onion_table(origins) %}
<div class="table-responsive">
<table class="table table-striped table-sm">
<thead>
<tr>
<th scope="col">Name</th>
<th scope="col">Description</th>
<th scope="col">Onion Service</th>
<th scope="col">Group</th>
<th scope="col">Actions</th>
</tr>
</thead>
<tbody>
{% for origin in origins %}
{% if not origin.destroyed %}
<tr>
<td>
<a href="https://{{ origin.domain_name }}" target="_bypass" rel="noopener noreferer"
class="btn btn-secondary btn-sm">⎋</a>
{{ origin.domain_name }}
</td>
<td>{{ origin.description }}</td>
<td>
{% if origin.onion() %}
<a href="https://{{ origin.onion() }}.onion" target="_bypass" rel="noopener noreferer"
class="btn btn-secondary btn-sm">⎋</a>
{{ origin.onion() }}.onion
{% endif %}
</td>
<td>
<a href="{{ url_for("portal.group.group_edit", group_id=origin.group.id) }}">{{ origin.group.group_name }}</a>
</td>
<td>
<a href="{{ url_for("portal.origin.origin_edit", origin_id=origin.id) }}"
class="btn btn-primary btn-sm">View/Edit</a>
</td>
</tr>
{% endif %}
{% endfor %}
</tbody>
</table>
</div>
{% endmacro %}
{% macro onions_table(onions) %}
<div class="table-responsive">
<table class="table table-striped table-sm">
<thead>
<tr>
<th scope="col">Domain Name</th>
<th scope="col">Onion Name</th>
<th scope="col">Description</th>
<th scope="col">Group</th>
<th scope="col">Actions</th>
</tr>
</thead>
<tbody>
{% for onion in onions %}
{% if not onion.destroyed %}
<tr>
<td>
<a href="https://{{ onion.domain_name }}" target="_bypass" rel="noopener noreferer"
class="btn btn-secondary btn-sm">⎋</a>
{{ onion.domain_name }}
</td>
<td>
<a href="https://{{ onion.onion_name }}.onion" target="_bypass" rel="noopener noreferer"
class="btn btn-secondary btn-sm">⎋</a>
{{ onion.onion_name }}
</td>
<td>{{ onion.description }}</td>
<td>
<a href="{{ url_for("portal.group.group_edit", group_id=onion.group.id) }}">{{ onion.group.group_name }}</a>
</td>
<td>
<a href="{{ url_for("portal.onion.onion_edit", onion_id=onion.id) }}"
class="btn btn-primary btn-sm">View/Edit</a>
</td>
</tr>
{% endif %}
{% endfor %}
</tbody>
</table>
</div>
{% endmacro %}
{% macro proxies_table(proxies) %}
<div class="table-responsive">
<table class="table table-striped table-sm">