Release v115 with router global logs and mobile header layout
This commit is contained in:
1 parent
0508438de0
commit
4ceb3d031a
39 files changed
+1181
-93
No files matched your search
@@ -2,6 +2,7 @@
|
||||
|
||||
KEY_FILE="${KEY_FILE:-/etc/owrt-remote/web.key}"
|
||||
AGENT="${AGENT:-/usr/sbin/owrt-remote}"
|
||||
LOG_HELPER="${OWRT_REMOTE_LOG_HELPER:-/usr/lib/owrt-remote/logs.sh}"
|
||||
OWRT_REMOTE_UI_VERSION="2026-07-02-mobile-terminal-batch-v25"
|
||||
PARAMS_FILE="${TMPDIR:-/tmp}/owrt-remote-cgi.$$"
|
||||
RESULT_TITLE=""
|
||||
@@ -131,6 +132,39 @@ set_result() {
|
||||
RESULT_TITLE="$1"
|
||||
RESULT_BODY="$2"
|
||||
RESULT_KIND="${3:-info}"
|
||||
if [ -r "$LOG_HELPER" ]; then
|
||||
printf '%s\n' "$RESULT_BODY" | sh "$LOG_HELPER" event "Панель: $RESULT_TITLE; результат=$RESULT_KIND" >/dev/null 2>&1 || true
|
||||
fi
|
||||
}
|
||||
|
||||
logs_response() {
|
||||
local mode
|
||||
mode="$1"
|
||||
if [ ! -r "$LOG_HELPER" ]; then
|
||||
printf 'Status: 503 Service Unavailable\r\nContent-Type: text/plain; charset=utf-8\r\nCache-Control: no-store\r\n\r\n'
|
||||
printf 'Сборщик логов не установлен. Установи локальный фикс целиком.\n'
|
||||
return
|
||||
fi
|
||||
if [ "$mode" = clear ]; then
|
||||
if [ "${REQUEST_METHOD:-GET}" != POST ]; then
|
||||
printf 'Status: 405 Method Not Allowed\r\nAllow: POST\r\nContent-Type: text/plain; charset=utf-8\r\n\r\n'
|
||||
return
|
||||
fi
|
||||
if sh "$LOG_HELPER" clear; then
|
||||
printf 'Content-Type: text/plain; charset=utf-8\r\nCache-Control: no-store\r\n\r\n'
|
||||
printf 'Логи Remote очищены.\n'
|
||||
else
|
||||
printf 'Status: 503 Service Unavailable\r\nContent-Type: text/plain; charset=utf-8\r\n\r\n'
|
||||
printf 'Не удалось очистить логи. Повтори через несколько секунд.\n'
|
||||
fi
|
||||
return
|
||||
fi
|
||||
printf 'Content-Type: text/plain; charset=utf-8\r\nCache-Control: no-store\r\nX-Content-Type-Options: nosniff\r\n'
|
||||
if [ "$mode" = download ]; then
|
||||
printf 'Content-Disposition: attachment; filename="owrt-remote-global-%s.log"\r\n' "$(date '+%Y%m%d-%H%M%S')"
|
||||
fi
|
||||
printf '\r\n'
|
||||
sh "$LOG_HELPER" read "$mode"
|
||||
}
|
||||
|
||||
save_config() {
|
||||
@@ -161,6 +195,9 @@ save_config() {
|
||||
uci_set wan_interface "$wan_interfaces"
|
||||
uci_set wan_dns "$(param wan_dns)"
|
||||
uci commit owrtremote
|
||||
if [ -r "$LOG_HELPER" ]; then
|
||||
printf '' | sh "$LOG_HELPER" event "Панель: сохранены настройки; enabled=$enabled; Hub=$(uci_get hub_url ''); VPS=$(uci_get vps_host ''):$(uci_get vps_port 8443); WAN_direct=$(uci_get wan_direct 0); WAN_selected=$wan_interfaces" >/dev/null 2>&1 || true
|
||||
fi
|
||||
set_result "Настройки сохранены" "Если менял Xray или VPS-поля, перезапусти сервис." "ok"
|
||||
}
|
||||
|
||||
@@ -437,7 +474,7 @@ render_page() {
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="owrt-remote-ui-version" content="$OWRT_REMOTE_UI_VERSION">
|
||||
<title>OpenWrt Remote Hub v114</title>
|
||||
<title>OpenWrt Remote Hub v115</title>
|
||||
<style>
|
||||
:root{color-scheme:dark;--bg:#07040f;--panel:rgba(19,14,32,.88);--text:#f7f2ff;--muted:#b9adc9;--line:rgba(169,126,255,.24);--blue:#7c3aed;--green:#22c55e;--red:#fb7185;--amber:#f59e0b;--teal:#a855f7;--grid:rgba(168,85,247,.16)}
|
||||
*{box-sizing:border-box}body{position:relative;min-height:100vh;margin:0;overflow-x:hidden;background-color:var(--bg);background-image:radial-gradient(circle at 12% 8%,rgba(168,85,247,.46),transparent 31%),radial-gradient(circle at 82% 12%,rgba(79,70,229,.38),transparent 30%),radial-gradient(circle at 50% 105%,rgba(236,72,153,.26),transparent 35%),linear-gradient(145deg,#07040f,#120a24 48%,#05030a),repeating-linear-gradient(0deg,transparent 0 30px,var(--grid) 31px),repeating-linear-gradient(90deg,transparent 0 30px,var(--grid) 31px);background-size:130% 130%,140% 140%,135% 135%,100% 100%,31px 31px,31px 31px;background-attachment:fixed;color:var(--text);font:14px/1.45 system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;animation:bgFlow 22s ease-in-out infinite alternate}
|
||||
@@ -458,8 +495,11 @@ form{margin:0}.formgrid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr
|
||||
.helperText{margin:0 0 12px;color:var(--muted)}.xrayApply{margin-top:14px;padding:16px;border:1px solid rgba(34,211,238,.42);border-radius:8px;background:linear-gradient(135deg,rgba(34,211,238,.16),rgba(124,58,237,.20),rgba(236,72,153,.11));box-shadow:0 18px 42px rgba(34,211,238,.10)}.xrayApply h3{margin:0 0 8px;font-size:16px;color:#a5f3fc}.scriptBox{width:100%;min-height:260px;resize:vertical;border:1px solid rgba(34,211,238,.28);border-radius:8px;background:rgba(255,255,255,.07);padding:12px;color:var(--text);font:12px/1.45 ui-monospace,SFMono-Regular,Consolas,monospace;white-space:pre;overflow:auto}
|
||||
.brandPanel{display:grid;grid-template-columns:repeat(2,minmax(0,132px));gap:8px}.brandPanel .titleRow,.brandPanel .links{grid-column:1/-1}.brandPanel .appBanner{width:100%;min-width:0}.brandPanel .links{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;margin-top:0}.brandPanel .links a{width:100%;min-width:0}
|
||||
.wanPicker{border:1px solid var(--line);border-radius:8px;background:rgba(8,5,18,.72)}.wanPicker summary{display:flex;align-items:center;justify-content:center;gap:5px;min-height:40px;padding:10px 11px;cursor:pointer;list-style:none;font-weight:700}.wanPicker summary::-webkit-details-marker{display:none}.wanPicker summary::after{content:"▾";margin-left:auto;color:var(--muted)}.wanPicker[open] summary::after{content:"▴"}.wanPickerList{display:flex;flex-direction:column;gap:4px;max-height:240px;overflow:auto;padding:6px;border-top:1px solid var(--line)}.wanChoice{display:flex;align-items:center;gap:10px;min-height:40px;padding:8px;border-radius:6px;cursor:pointer;overflow-wrap:anywhere}.wanChoice:hover{background:rgba(255,255,255,.08)}.wanChoice input{width:18px;height:18px;min-width:18px;padding:0;margin:0;accent-color:var(--blue)}.wanPicked{margin-top:6px;font-size:12px;color:var(--muted);overflow-wrap:anywhere}
|
||||
.globalLogsPanel[hidden]{display:none}.globalLogsPanel{margin-top:16px}.globalLogsPanel .actions{justify-content:flex-start;margin:0 0 12px}.globalLogsText{margin:12px 0 0;max-height:55vh;overflow:auto;white-space:pre-wrap;overflow-wrap:anywhere;word-break:break-word;font:12px/1.5 ui-monospace,SFMono-Regular,Consolas,monospace;background:rgba(8,5,18,.72);border:1px solid var(--line);border-radius:8px;padding:12px;min-height:150px}.globalLogsStatus{color:var(--muted);overflow-wrap:anywhere}.globalLogsToggle{cursor:pointer;font-family:inherit;border-color:rgba(34,197,94,.65);background:var(--green);color:#07120a;box-shadow:0 10px 22px rgba(34,197,94,.22)}
|
||||
.globalLogsNote{margin:0 0 12px;padding:10px 12px;border:1px solid rgba(245,158,11,.35);border-left:3px solid var(--amber);border-radius:8px;background:rgba(245,158,11,.10);color:#fde68a;font-size:12px;line-height:1.5;overflow-wrap:anywhere}
|
||||
@media(max-width:820px){.grid,.formgrid,.metrics{grid-template-columns:1fr}.linkMetric{grid-column:span 1}.metricLine{align-items:center;justify-content:center}.miniGo{width:auto;justify-content:center;display:inline-flex}.hero{align-items:flex-start;flex-direction:column}.topActions{justify-content:flex-start;padding-top:0}.wrap{padding:14px}h1{font-size:24px}.appBanner{width:auto;max-width:100%;justify-content:center;min-height:36px;padding:8px 12px}.panelHead{align-items:stretch;flex-direction:column}.headActionForm .btn{width:100%}.actions .btn,.actions button{width:100%}}
|
||||
@media(max-width:820px){.brandPanel{grid-template-columns:repeat(2,minmax(0,1fr));width:100%}.brandPanel .appBanner{width:100%}}
|
||||
@media(max-width:820px){.hero{gap:10px}.hero .brand{width:100%;min-width:0}.hero .uiPill,.hero .appBanner{width:100%;min-width:0;min-height:44px}.hero .appBanner{line-height:1.2}.topActions{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));width:100%;gap:8px}.vpnCard,.returnCard{width:100%;min-width:0}.returnCard{grid-column:1/-1}.backBtn{white-space:normal;text-align:center}}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
@@ -468,7 +508,7 @@ form{margin:0}.formgrid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr
|
||||
<div class="brand">
|
||||
<div class="brandPanel">
|
||||
<div class="titleRow">
|
||||
<h1 class="appBanner"><span>OpenWrt Remote Hub <span class="appBannerVersion">v114</span></span></h1>
|
||||
<h1 class="appBanner"><span>OpenWrt Remote Hub <span class="appBannerVersion">v115</span></span></h1>
|
||||
</div>
|
||||
<div class="links">
|
||||
<a class="uiPill" href="https://t.me/kzolotarev95" target="_blank" rel="noopener noreferrer">Telegram</a>
|
||||
@@ -483,12 +523,25 @@ form{margin:0}.formgrid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr
|
||||
<span>NetHaven VPN</span>
|
||||
</a>
|
||||
</div>
|
||||
<button class="uiPill globalLogsToggle" id="globalLogsToggle" type="button" aria-expanded="false" aria-controls="globalLogsPanel">Глобал логи</button>
|
||||
<div class="returnCard">
|
||||
<a class="uiPill backBtn" href="/cgi-bin/luci/">Вернуться в службы OpenWrt</a>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="panel globalLogsPanel" id="globalLogsPanel" hidden>
|
||||
<div class="panelHead"><h2>Глобал логи</h2><button class="btn" id="globalLogsClose" type="button">Закрыть</button></div>
|
||||
<blockquote class="globalLogsNote">Действия панели, Heartbeat, WAN и ошибки Xray этого роутера. Журнал хранится в оперативной памяти, очищается после перезагрузки и каждые 24 часа. Максимум около 2 МБ. Ключи и пароли скрываются.</blockquote>
|
||||
<div class="actions">
|
||||
<a class="btn" href="?key=$(h "$key")&action=logs_download">Скачать логи</a>
|
||||
<button class="btn" id="globalLogsLive" type="button">Запустить в реальном времени</button>
|
||||
<button class="btn bad" id="globalLogsClear" type="button">Очистить логи</button>
|
||||
</div>
|
||||
<div class="globalLogsStatus" id="globalLogsStatus" role="status">Сохранённые записи показаны ниже. Нажми «Запустить в реальном времени», чтобы обновлять их каждые 3 секунды.</div>
|
||||
<pre class="globalLogsText" id="globalLogsText" tabindex="0">Загрузка записей журнала…</pre>
|
||||
</section>
|
||||
|
||||
<section class="grid">
|
||||
<div class="panel">
|
||||
<h2>Состояние</h2>
|
||||
@@ -594,6 +647,118 @@ EOF
|
||||
</section>
|
||||
</main>
|
||||
<script>
|
||||
(function() {
|
||||
var panel = document.getElementById('globalLogsPanel');
|
||||
var toggle = document.getElementById('globalLogsToggle');
|
||||
var close = document.getElementById('globalLogsClose');
|
||||
var live = document.getElementById('globalLogsLive');
|
||||
var clear = document.getElementById('globalLogsClear');
|
||||
var output = document.getElementById('globalLogsText');
|
||||
var status = document.getElementById('globalLogsStatus');
|
||||
var timer = null, controller = null, generation = 0, running = false;
|
||||
function endpoint(action) {
|
||||
var url = new URL(window.location.href);
|
||||
url.searchParams.set('action', action);
|
||||
url.searchParams.delete('_');
|
||||
return url;
|
||||
}
|
||||
function stop() {
|
||||
running = false;
|
||||
generation++;
|
||||
if (timer !== null) window.clearTimeout(timer);
|
||||
timer = null;
|
||||
if (controller) controller.abort();
|
||||
controller = null;
|
||||
live.textContent = 'Запустить в реальном времени';
|
||||
live.setAttribute('aria-pressed', 'false');
|
||||
}
|
||||
async function refresh(once) {
|
||||
if ((!running && !once) || panel.hidden || document.hidden) return;
|
||||
var current = generation;
|
||||
var request = new AbortController();
|
||||
controller = request;
|
||||
var timeout = window.setTimeout(function() { request.abort(); }, 10000);
|
||||
try {
|
||||
var response = await fetch(endpoint('logs_live'), {cache: 'no-store', signal: request.signal});
|
||||
if (!response.ok) throw new Error('HTTP ' + response.status);
|
||||
var text = await response.text();
|
||||
if (current !== generation || (!running && !once)) return;
|
||||
if ((response.headers.get('Content-Type') || '').indexOf('text/plain') !== 0) throw new Error('Доступ к журналу завершён. Открой панель заново.');
|
||||
var atBottom = output.scrollHeight - output.clientHeight - output.scrollTop < 24;
|
||||
var previousTop = output.scrollTop;
|
||||
if (output.textContent !== text) {
|
||||
output.textContent = text || (once ? 'Журнал пока пуст. Новые записи появятся после действий в панели или событий Remote. Нажми «Запустить в реальном времени», чтобы увидеть их.' : 'Журнал пуст. Новые события появятся автоматически.');
|
||||
output.scrollTop = atBottom ? output.scrollHeight : previousTop;
|
||||
}
|
||||
status.textContent = (once ? 'Сохранённые записи' : 'Просмотр в реальном времени') + ' · обновлено ' + new Date().toLocaleTimeString() + ' · последние 64 КБ журнала' + (once ? '. Для автообновления нажми «Запустить в реальном времени».' : '');
|
||||
} catch (error) {
|
||||
if (current === generation && (running || once)) {
|
||||
status.textContent = 'Не удалось получить логи: ' + error.message + (once ? '. Для повторной загрузки нажми «Запустить в реальном времени».' : '. Повтор через 3 секунды.');
|
||||
if (once) output.textContent = 'Записи журнала не загружены. Ошибка указана выше.';
|
||||
}
|
||||
} finally {
|
||||
window.clearTimeout(timeout);
|
||||
if (controller === request) controller = null;
|
||||
if (!once && current === generation && running && !panel.hidden && !document.hidden) timer = window.setTimeout(refresh, 3000);
|
||||
}
|
||||
}
|
||||
toggle.addEventListener('click', function() {
|
||||
panel.hidden = !panel.hidden;
|
||||
toggle.setAttribute('aria-expanded', String(!panel.hidden));
|
||||
if (panel.hidden) { stop(); status.textContent = 'Просмотр остановлен.'; }
|
||||
else {
|
||||
stop();
|
||||
output.textContent = 'Загрузка записей журнала…';
|
||||
status.textContent = 'Загружаю сохранённые записи с роутера…';
|
||||
refresh(true);
|
||||
}
|
||||
});
|
||||
close.addEventListener('click', function() {
|
||||
panel.hidden = true;
|
||||
toggle.setAttribute('aria-expanded', 'false');
|
||||
stop();
|
||||
status.textContent = 'Просмотр остановлен.';
|
||||
});
|
||||
live.addEventListener('click', function() {
|
||||
if (running) { stop(); status.textContent = 'Просмотр остановлен.'; return; }
|
||||
stop();
|
||||
running = true;
|
||||
generation++;
|
||||
live.textContent = 'Остановить просмотр';
|
||||
live.setAttribute('aria-pressed', 'true');
|
||||
refresh();
|
||||
});
|
||||
clear.addEventListener('click', async function() {
|
||||
var resume = running;
|
||||
stop();
|
||||
clear.disabled = true;
|
||||
live.disabled = true;
|
||||
var request = new AbortController();
|
||||
var timeout = window.setTimeout(function() { request.abort(); }, 10000);
|
||||
try {
|
||||
var response = await fetch(endpoint('logs_clear'), {method: 'POST', cache: 'no-store', signal: request.signal});
|
||||
var text = await response.text();
|
||||
if (!response.ok || (response.headers.get('Content-Type') || '').indexOf('text/plain') !== 0) throw new Error('HTTP ' + response.status);
|
||||
output.textContent = 'Журнал очищен.';
|
||||
status.textContent = text.trim();
|
||||
} catch (error) { status.textContent = 'Не удалось очистить логи: ' + error.message; }
|
||||
finally {
|
||||
window.clearTimeout(timeout);
|
||||
clear.disabled = false;
|
||||
live.disabled = false;
|
||||
if (resume && !panel.hidden) { running = true; generation++; live.textContent = 'Остановить просмотр'; live.setAttribute('aria-pressed', 'true'); refresh(); }
|
||||
}
|
||||
});
|
||||
document.addEventListener('visibilitychange', function() {
|
||||
if (!running) return;
|
||||
generation++;
|
||||
if (timer !== null) window.clearTimeout(timer);
|
||||
timer = null;
|
||||
if (controller) controller.abort();
|
||||
if (!document.hidden) refresh();
|
||||
});
|
||||
window.addEventListener('pagehide', stop);
|
||||
})();
|
||||
document.querySelectorAll('[data-wan-picker]').forEach(function(picker) {
|
||||
var field = picker.closest('.wanField');
|
||||
var inputs = Array.from(picker.querySelectorAll('input[name="wan_interface"]'));
|
||||
@@ -620,6 +785,18 @@ fi
|
||||
|
||||
action="$(param action)"
|
||||
|
||||
case "$action" in
|
||||
logs_download) logs_response download; exit 0 ;;
|
||||
logs_live) logs_response live; exit 0 ;;
|
||||
logs_clear) logs_response clear; exit 0 ;;
|
||||
esac
|
||||
|
||||
if [ "${REQUEST_METHOD:-GET}" = POST ] && [ -n "$action" ] && [ -r "$LOG_HELPER" ]; then
|
||||
printf '' | sh "$LOG_HELPER" event "Панель: действие=$action; начало" >/dev/null 2>&1 || true
|
||||
elif [ "${REQUEST_METHOD:-GET}" = GET ] && [ -z "$action" ] && [ -r "$LOG_HELPER" ]; then
|
||||
printf '' | sh "$LOG_HELPER" event 'Панель: открыта' >/dev/null 2>&1 || true
|
||||
fi
|
||||
|
||||
if [ "$action" = "download_config" ]; then
|
||||
http_json
|
||||
"$AGENT" render-client --stdout 2>&1
|
||||
|
||||
Reference in new issue
Block a user