From 12794ec19075bcf3d6c9f8e258d900435e29fd63 Mon Sep 17 00:00:00 2001 From: Iain Learmonth Date: Fri, 13 May 2022 16:20:44 +0100 Subject: [PATCH] eotk: generate configuration in portal --- app/portal/eotk.py | 12 +++++++++++- app/portal/templates/sites.conf.j2 | 18 ++++++++++++++++++ app/portal/templates/tables.html.j2 | 4 ++-- 3 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 app/portal/templates/sites.conf.j2 diff --git a/app/portal/eotk.py b/app/portal/eotk.py index d730c1a..327eb7c 100644 --- a/app/portal/eotk.py +++ b/app/portal/eotk.py @@ -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/") +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") diff --git a/app/portal/templates/sites.conf.j2 b/app/portal/templates/sites.conf.j2 new file mode 100644 index 0000000..14e3ac7 --- /dev/null +++ b/app/portal/templates/sites.conf.j2 @@ -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 %} diff --git a/app/portal/templates/tables.html.j2 b/app/portal/templates/tables.html.j2 index a5e1f01..235c930 100644 --- a/app/portal/templates/tables.html.j2 +++ b/app/portal/templates/tables.html.j2 @@ -98,8 +98,8 @@ {% endfor %} - Generate Configuration + Preview Configuration {% endif %}