eotk: generate configuration in portal

This commit is contained in:
Iain Learmonth 2022-05-13 16:20:44 +01:00
parent ce520b87a5
commit 12794ec190
3 changed files with 31 additions and 3 deletions

View file

@ -1,6 +1,7 @@
from flask import render_template, Blueprint
from flask import render_template, Blueprint, Response
from sqlalchemy import desc
from app.models.base import Group
from app.models.onions import Eotk
bp = Blueprint("eotk", __name__)
@ -14,3 +15,12 @@ def eotk_list():
title="EOTK Instances",
item="eotk",
items=instances)
@bp.route("/conf/<group_id>")
def eotk_conf(group_id: int):
from app import app
group = Group.query.filter(Group.id == group_id).first()
return Response(render_template("sites.conf.j2",
bypass_token=app.config["BYPASS_TOKEN"],
group=group), content_type="text/plain")

View file

@ -0,0 +1,18 @@
set log_separate 1
set nginx_resolver 127.0.0.53 ipv6=off
set nginx_cache_seconds 60
set nginx_cache_size 64m
set nginx_tmpfile_size 8m
set x_from_onion_value 1
set inject_headers_upstream Bypass-Rate-Limit-Token,{{ bypass_token }}
foreignmap facebookwkhpilnemxj7asaniu7vnjjbiltxjqhye3mhbshg7kx5tfyd.onion facebook.com
foreignmap twitter3e4tixl4xyajtrzo62zg5vztmjuricljdp2c5kshju4avyoid.onion twitter.com
set project sites
{% for o in group.onions %}
hardmap {{ o.onion_name }} {{ o.domain_name }}
{%- endfor %}

View file

@ -98,8 +98,8 @@
{% endfor %}
</td>
<td>
<a href="#"
class="btn btn-primary btn-sm">Generate Configuration</a>
<a href="{{ url_for("portal.eotk.eotk_conf", group_id=instance.group_id) }}"
class="btn btn-primary btn-sm">Preview Configuration</a>
</td>
</tr>
{% endif %}