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)}
+
+
@@ -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)} }