diff --git a/gui/app.py b/gui/app.py index 114935c..f6bfc64 100644 --- a/gui/app.py +++ b/gui/app.py @@ -444,6 +444,27 @@ def peer_delete(peer_id: int): return redirect(url_for("index")) +@app.post("/peers/delete-by-key") +def peer_delete_by_key(): + pk = (request.form.get("public_key") or "").strip() + if not pk: + flash("Не найден public key", "error") + return redirect(url_for("index")) + + try: + run(["/usr/local/sbin/wg-peerctl", "remove", "--client-public-key", pk]) + except Exception: + pass + + with db_conn() as conn: + cur = conn.cursor() + cur.execute("DELETE FROM peers WHERE public_key = ?", (pk,)) + conn.commit() + + flash("Peer удален", "ok") + return redirect(url_for("index")) + + @app.route("/scripts") def scripts(): commands = { diff --git a/gui/templates/index.html b/gui/templates/index.html index f297811..5a93509 100644 --- a/gui/templates/index.html +++ b/gui/templates/index.html @@ -28,7 +28,10 @@ {% else %} - - +
+ + +
{% endif %}