GUI: status accuracy + remove-only action; sync script peer names on exists
This commit is contained in:
@@ -18,7 +18,7 @@ WG_INTERFACE = os.environ.get("WG_INTERFACE", "wg0")
|
||||
WG_META_FILE = os.environ.get("WG_META_FILE", "/etc/wireguard/wg-meta.env")
|
||||
ADMIN_USER = os.environ.get("ADMIN_USER", "admin")
|
||||
ADMIN_PASSWORD = os.environ.get("ADMIN_PASSWORD", "")
|
||||
ONLINE_WINDOW_SEC = int(os.environ.get("ONLINE_WINDOW_SEC", "1800"))
|
||||
ONLINE_WINDOW_SEC = int(os.environ.get("ONLINE_WINDOW_SEC", "120"))
|
||||
|
||||
|
||||
def db_conn():
|
||||
|
||||
@@ -14,6 +14,7 @@ main { padding: 22px; }
|
||||
label { display: grid; gap: 6px; }
|
||||
input, select, button { padding: 10px; border-radius: 10px; border: 1px solid #bad2bf; font-size: 14px; }
|
||||
button { background: var(--brand); color: #fff; border: 0; font-weight: 700; cursor: pointer; }
|
||||
button.danger { background: #b42318; }
|
||||
table { width: 100%; border-collapse: collapse; background: white; border: 1px solid #d7e7da; }
|
||||
th, td { border-bottom: 1px solid #e0ece2; padding: 8px; font-size: 13px; text-align: left; vertical-align: top; }
|
||||
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
|
||||
|
||||
@@ -24,17 +24,8 @@
|
||||
<td>
|
||||
{% if p.id %}
|
||||
<a href="{{ url_for('peer_view', peer_id=p.id) }}">QR/Config</a>
|
||||
{% if p.status == 'online' %}
|
||||
<form method="post" action="{{ url_for('peer_disable', peer_id=p.id) }}" style="display:inline">
|
||||
<button type="submit">Отключить</button>
|
||||
</form>
|
||||
{% else %}
|
||||
<form method="post" action="{{ url_for('peer_enable', peer_id=p.id) }}" style="display:inline">
|
||||
<button type="submit">Включить</button>
|
||||
</form>
|
||||
{% endif %}
|
||||
<form method="post" action="{{ url_for('peer_delete', peer_id=p.id) }}" style="display:inline" onsubmit="return confirm('Удалить peer?')">
|
||||
<button type="submit">Удалить</button>
|
||||
<button type="submit" class="danger">Удалить</button>
|
||||
</form>
|
||||
{% else %}
|
||||
-
|
||||
|
||||
@@ -257,7 +257,13 @@ cmd_add() {
|
||||
|
||||
if peer_exists_by_pubkey "$client_pubkey"; then
|
||||
local existing_addr
|
||||
local existing_allowed
|
||||
existing_addr="$(extract_peer_address_by_pubkey "$client_pubkey")"
|
||||
existing_allowed="${existing_addr:-}"
|
||||
if [[ -n "$client_routes" ]]; then
|
||||
existing_allowed="${existing_allowed},${client_routes}"
|
||||
fi
|
||||
sync_gui_db_upsert_peer "$client_name" "$client_pubkey" "${existing_addr:-}" "$client_routes" "$client_psk" "${existing_allowed}" 1
|
||||
cat <<EOF_OUT
|
||||
STATUS=exists
|
||||
CLIENT_NAME=$client_name
|
||||
|
||||
Reference in New Issue
Block a user