From b41e5c7dc8dbb70c1f0a3e7622f5016ecb4fd7e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BD=D0=B4=D1=80=D0=B5=D0=B9=20=D0=91=D0=BE=D0=B1?= =?UTF-8?q?=D1=8B=D1=80=D0=B5=D0=B2?= Date: Tue, 28 Apr 2026 20:06:29 +0300 Subject: [PATCH] =?UTF-8?q?feat:=20=D0=BA=D0=BD=D0=BE=D0=BF=D0=BA=D0=B0=20?= =?UTF-8?q?=C2=AB=D0=A1=D0=BA=D0=B0=D1=87=D0=B0=D1=82=D1=8C=20.conf=C2=BB?= =?UTF-8?q?=20=D0=B2=20=D0=BC=D0=BE=D0=B4=D0=B0=D0=BB=D0=B5=20WireGuard=20?= =?UTF-8?q?=D0=BA=D0=BE=D0=BD=D1=84=D0=B8=D0=B3=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Добавлена кнопка «⬇ Скачать .conf» рядом с «Копировать». Имя файла: wg0-server.conf для VPS, hydravpn-{name}.conf для роутера. Hint роутера обновлён: «Загрузить из файла» вместо «Вставить из буфера». --- server/templates/index.html | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/server/templates/index.html b/server/templates/index.html index 508068e..49e36a8 100644 --- a/server/templates/index.html +++ b/server/templates/index.html @@ -267,8 +267,9 @@ input[type=text]:focus,input[type=password]:focus{border-color:var(--accent)}

WireGuard конфиг

-
+
+
@@ -648,10 +649,13 @@ async function wgDeploy(name){ } catch(e){ log.textContent += '\nОшибка: '+e; } } +let _wgCfgFilename = 'wg0.conf'; + async function wgShowServerConfig(){ try { const r = await fetch('/api/wireguard/server-config', {headers: authHdr()}); const text = await r.text(); + _wgCfgFilename = 'wg0-server.conf'; document.getElementById('wg-cfg-title').textContent = 'wg0.conf — конфиг VPS сервера'; document.getElementById('wg-cfg-text').value = text; document.getElementById('wg-cfg-hint').textContent = 'Этот файл лежит на VPS в /etc/wireguard/wg0.conf'; @@ -663,9 +667,10 @@ async function wgShowRouterConfig(name){ try { const r = await fetch(`/api/routers/${encodeURIComponent(name)}/wireguard-config`, {headers: authHdr()}); const text = await r.text(); + _wgCfgFilename = `hydravpn-${name}.conf`; document.getElementById('wg-cfg-title').textContent = `wg0.conf — конфиг роутера «${name}»`; document.getElementById('wg-cfg-text').value = text; - document.getElementById('wg-cfg-hint').textContent = 'Можно вручную добавить в Keenetic: Интернет → WireGuard → Добавить подключение → Вставить из буфера'; + document.getElementById('wg-cfg-hint').textContent = 'Keenetic: Интернет → WireGuard → Загрузить из файла'; document.getElementById('wg-cfg-modal').style.display = 'flex'; } catch(e){ alert('Ошибка: '+e); } } @@ -676,6 +681,16 @@ function copyWgCfg(){ else { document.getElementById('wg-cfg-text').select(); document.execCommand('copy'); } } +function downloadWgCfg(){ + const text = document.getElementById('wg-cfg-text').value; + const blob = new Blob([text], {type: 'text/plain'}); + const a = document.createElement('a'); + a.href = URL.createObjectURL(blob); + a.download = _wgCfgFilename; + a.click(); + URL.revokeObjectURL(a.href); +} + // ── SETTINGS ────────────────────────────────────────────────────────────── async function changePwd(){ const p1=document.getElementById('new-pwd').value; const p2=document.getElementById('new-pwd2').value; if(p1!==p2){sm('pwd-msg','err','❌ Пароли не совпадают');return;} if(p1.length<4){sm('pwd-msg','err','❌ Минимум 4 символа');return;} try{ const r=await fetch('/api/set_password',{method:'POST',headers:authHdr(),body:JSON.stringify({password:p1})}); if(r.ok){ sessionStorage.setItem('hm_pass',p1); sm('pwd-msg','ok','✅ Пароль сохранён'); document.getElementById('new-pwd').value=''; document.getElementById('new-pwd2').value=''; } }catch(e){sm('pwd-msg','err','❌ '+e)} }