proxies: immediate expiration of proxies via the portal
This commit is contained in:
parent
5b9946c431
commit
29870639b8
2 changed files with 23 additions and 0 deletions
|
@ -19,6 +19,27 @@ def proxy_list() -> ResponseReturnValue:
|
|||
items=proxies)
|
||||
|
||||
|
||||
@bp.route("/expire/<proxy_id>", methods=['GET', 'POST'])
|
||||
def proxy_expire(proxy_id: int) -> ResponseReturnValue:
|
||||
proxy = Proxy.query.filter(Proxy.id == proxy_id, Proxy.destroyed.is_(None)).first()
|
||||
if proxy is None:
|
||||
return Response(render_template("error.html.j2",
|
||||
header="404 Proxy Not Found",
|
||||
message="The requested proxy could not be found. It may have already been "
|
||||
"destroyed."))
|
||||
form = LifecycleForm()
|
||||
if form.validate_on_submit():
|
||||
proxy.destroy()
|
||||
db.session.commit()
|
||||
flash("Proxy will be shortly retired.", "success")
|
||||
return redirect(url_for("portal.origin.origin_edit", origin_id=proxy.origin.id))
|
||||
return render_template("lifecycle.html.j2",
|
||||
header=f"Expire proxy for {proxy.origin.domain_name} immediately?",
|
||||
message=proxy.url,
|
||||
section="proxy",
|
||||
form=form)
|
||||
|
||||
|
||||
@bp.route("/block/<proxy_id>", methods=['GET', 'POST'])
|
||||
def proxy_block(proxy_id: int) -> ResponseReturnValue:
|
||||
proxy = Proxy.query.filter(Proxy.id == proxy_id, Proxy.destroyed.is_(None)).first()
|
||||
|
|
|
@ -388,6 +388,8 @@
|
|||
{% if proxy.deprecated %}
|
||||
<a href="#" class="disabled btn btn-sm btn-outline-dark">Expiring
|
||||
in {{ proxy.deprecated | mirror_expiry }}</a>
|
||||
<a href="{{ url_for("portal.proxy.proxy_expire", proxy_id=proxy.id) }}"
|
||||
class="btn btn-danger btn-sm">Expire</a>
|
||||
{% else %}
|
||||
<a href="{{ url_for("portal.proxy.proxy_block", proxy_id=proxy.id) }}"
|
||||
class="btn btn-warning btn-sm">Mark blocked</a>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue