Release v116 with VPS router logs and reliable log delivery
Add per-router VPS log archives available offline, live delivery and last reported service state. Keep router logs in RAM with bounded rotation and deduplication. Align log pages and mobile statistics, and bump application and deployment tools to v116.
This commit is contained in:
1 parent
4ceb3d031a
commit
aa7970c98c
43 files changed
+1658
-121
No files matched your search
@@ -66,6 +66,7 @@ start_service() {
|
||||
|
||||
procd_open_instance xray
|
||||
procd_set_param command /usr/sbin/owrt-remote run
|
||||
procd_set_param env OWRT_REMOTE_SERVICE_LOG=1
|
||||
procd_set_param respawn 3600 5 5
|
||||
procd_set_param stdout 1
|
||||
procd_set_param stderr 1
|
||||
@@ -73,6 +74,7 @@ start_service() {
|
||||
|
||||
procd_open_instance heartbeat
|
||||
procd_set_param command /usr/sbin/owrt-remote heartbeat-loop
|
||||
procd_set_param env OWRT_REMOTE_SERVICE_LOG=1
|
||||
procd_set_param respawn 3600 5 5
|
||||
procd_set_param stdout 1
|
||||
procd_set_param stderr 1
|
||||
|
||||
@@ -11,4 +11,10 @@ start_service() {
|
||||
procd_set_param stdout 1
|
||||
procd_set_param stderr 1
|
||||
procd_close_instance
|
||||
|
||||
procd_open_instance archive
|
||||
procd_set_param command /bin/sh /usr/lib/owrt-remote/logs.sh sync
|
||||
procd_set_param env OWRT_REMOTE_SERVICE_LOG=1
|
||||
procd_set_param respawn 3600 5 5
|
||||
procd_close_instance
|
||||
}
|
||||
@@ -5,8 +5,26 @@ LOG_LIMIT=1048576
|
||||
LOG_KEEP_SECONDS=86400
|
||||
|
||||
log_clock() { cut -d. -f1 /proc/uptime; }
|
||||
log_ram_storage() {
|
||||
local resolved parent
|
||||
if [ -e "$LOG_DIR" ] || [ -L "$LOG_DIR" ]; then
|
||||
resolved="$(readlink -f "$LOG_DIR")" || return 1
|
||||
else
|
||||
# BusyBox realpath may require the last component to exist.
|
||||
# Resolve the existing parent before creating the journal directory.
|
||||
parent="$(readlink -f "$(dirname "$LOG_DIR")")" || return 1
|
||||
resolved="$parent/$(basename "$LOG_DIR")"
|
||||
fi
|
||||
awk -v path="$resolved" '
|
||||
(path == $2 || index(path, $2 "/") == 1 || $2 == "/") && length($2) > best {
|
||||
best = length($2); filesystem = $3
|
||||
}
|
||||
END { exit(filesystem == "tmpfs" ? 0 : 1) }
|
||||
' /proc/mounts
|
||||
}
|
||||
log_init() {
|
||||
umask 077
|
||||
log_ram_storage || { printf 'Remote journal requires RAM (tmpfs); refusing persistent storage.\n' >&2; return 1; }
|
||||
mkdir -p "$LOG_DIR" || return 1
|
||||
chmod 700 "$LOG_DIR"
|
||||
}
|
||||
@@ -41,8 +59,22 @@ log_unlock() {
|
||||
log_reset_locked() {
|
||||
: >"$LOG_DIR/current.log"
|
||||
rm -f "$LOG_DIR/previous.log"
|
||||
rm -f "$LOG_DIR/facts" "$LOG_DIR/facts.new" "$LOG_DIR/heartbeat-ok"
|
||||
rm -f "$LOG_DIR/journal-id" "$LOG_DIR/total" "$LOG_DIR/sync-ack"
|
||||
log_clock >"$LOG_DIR/age"
|
||||
}
|
||||
log_cursor_locked() {
|
||||
local total
|
||||
if [ ! -s "$LOG_DIR/journal-id" ]; then
|
||||
cat /proc/sys/kernel/random/uuid >"$LOG_DIR/journal-id" 2>/dev/null ||
|
||||
printf '%s-%s-%s\n' "$(date +%s)" "$(log_clock)" "$$" >"$LOG_DIR/journal-id"
|
||||
fi
|
||||
if [ ! -s "$LOG_DIR/total" ]; then
|
||||
total="$(wc -c <"$LOG_DIR/current.log")"
|
||||
[ ! -f "$LOG_DIR/previous.log" ] || total=$((total + $(wc -c <"$LOG_DIR/previous.log")))
|
||||
printf '%s\n' "$total" >"$LOG_DIR/total"
|
||||
fi
|
||||
}
|
||||
log_maintain_locked() {
|
||||
local now age
|
||||
now="$(log_clock)"
|
||||
@@ -54,29 +86,83 @@ log_maintain_locked() {
|
||||
}
|
||||
log_redact() {
|
||||
# Never retain command blocks containing credentials or authenticated URLs.
|
||||
LC_ALL=C awk '
|
||||
LC_ALL=C awk -v fallback="${1:-OK}" '
|
||||
{
|
||||
line = substr($0, 1, 4096); lower = tolower(line)
|
||||
# Old info/access output may still arrive until Xray restarts.
|
||||
if (lower ~ /\[(info|debug)\]/ || lower ~ / from .* accepted / || lower ~ /a unified platform for anti-censorship/) next
|
||||
level = fallback
|
||||
if (line ~ /^\[(OK|WARN|ERROR)\]/) { level = substr(line, 2, index(line, "]") - 2); sub(/^\[[^]]+\][ ]*/, "", line) }
|
||||
else if (lower ~ /core: xray .* started/) level = "OK"
|
||||
else if (lower ~ /\[error\]|ошибка|Ошибка|ОШИБКА|не удалось|Не удалось|результат=bad|failed|cannot |could not |error:|syntax error|permission denied|network is unreachable|connection refused|connection reset|timed out|not permitted|no selected wan|wan has no|wan direct requires|already used by another rule|does not belong to remote|не применилось|dns failed|crash loop/) level = "ERROR"
|
||||
else if (lower ~ /\[warn(ing)?\]|предупреждение|Предупреждение|результат=warn|retry|not ready|missing|не найден|restart postponed|dns unavailable|fallback|reconnecting|restarting|failover/) level = "WARN"
|
||||
if (lower ~ /(authorization|hub_token|vless_uuid|ssh_vless_uuid|password|passwd|web[._ -]?key|[?&]key=|[?&]token=|"uuid"|"privatekey"|"password")/ ||
|
||||
lower ~ /[0-9a-f][0-9a-f][0-9a-f][0-9a-f]-[0-9a-f-]+-[0-9a-f-]+-[0-9a-f-]+/)
|
||||
print "[строка с ключом или паролем скрыта]"
|
||||
else print line
|
||||
line = "[строка с ключом или паролем скрыта]"
|
||||
print "[" level "] " line
|
||||
}'
|
||||
}
|
||||
log_new_fact_locked() {
|
||||
local key now heartbeat new_fact
|
||||
# Compare event text without syslog timestamp, facility, PID or Xray time.
|
||||
key="$(printf '%s\n' "$1" | tr '\t' ' ' | sed -e 's/^\[[^]]*\] *//' -e 's/.*owrt-remote\(\[[0-9][0-9]*\]\)\{0,1\}: *//' -e 's/^[0-9][0-9]*\/[0-9/:. ]* *//' -e 's/ *(\([0-9][0-9]*\)\/[0-9][0-9]*)//')"
|
||||
heartbeat=0
|
||||
case "$key" in
|
||||
'Heartbeat: OK;'*)
|
||||
heartbeat=1
|
||||
if [ "$(cat "$LOG_DIR/heartbeat-ok" 2>/dev/null)" = "$key" ]; then return 1; fi
|
||||
printf '%s\n' "$key" >"$LOG_DIR/heartbeat-ok"
|
||||
# A recovery lets a later failure with the same cause appear again.
|
||||
if [ -f "$LOG_DIR/facts" ]; then
|
||||
awk -F '\t' '$2 !~ /Heartbeat:|heartbeat failed/ { print }' "$LOG_DIR/facts" >"$LOG_DIR/facts.new"
|
||||
mv -f "$LOG_DIR/facts.new" "$LOG_DIR/facts"
|
||||
fi ;;
|
||||
esac
|
||||
if [ "$heartbeat" = 1 ]; then return 0; fi
|
||||
key="${1%%]*}] $key"
|
||||
now="$(log_clock)"
|
||||
# A bounded cache suppresses repeated identical facts while they continue.
|
||||
# After a quiet period a new occurrence is recorded, rather than lost forever.
|
||||
awk -F '\t' -v now="$now" -v key="$key" '
|
||||
$2 == key { if (now - $1 < 120 && now >= $1) repeated = 1; next }
|
||||
{ saved[++n] = $0 }
|
||||
END {
|
||||
for (i = (n > 63 ? n - 62 : 1); i <= n; i++) print saved[i]
|
||||
print now "\t" key
|
||||
exit(repeated ? 1 : 0)
|
||||
}' "$LOG_DIR/facts" >"$LOG_DIR/facts.new" 2>/dev/null
|
||||
new_fact=$?
|
||||
mv -f "$LOG_DIR/facts.new" "$LOG_DIR/facts"
|
||||
[ "$new_fact" = 0 ] || return 1
|
||||
case "$key" in
|
||||
*Heartbeat:*|*'heartbeat failed'*)
|
||||
case "$1" in '[ERROR]'*|'[WARN]'*) rm -f "$LOG_DIR/heartbeat-ok" ;; esac ;;
|
||||
*'Сервис: запуск') rm -f "$LOG_DIR/heartbeat-ok" ;;
|
||||
esac
|
||||
return 0
|
||||
}
|
||||
log_append() {
|
||||
local line size
|
||||
# Process one bounded line at a time and release the lock between writes.
|
||||
log_redact | while IFS= read -r line; do
|
||||
log_redact "${1:-OK}" | while IFS= read -r line; do
|
||||
log_lock || exit 1
|
||||
trap 'log_unlock' EXIT
|
||||
trap 'exit 0' INT TERM
|
||||
log_maintain_locked
|
||||
log_cursor_locked
|
||||
[ -f "$LOG_DIR/facts" ] || : >"$LOG_DIR/facts"
|
||||
if ! log_new_fact_locked "$line"; then
|
||||
log_unlock
|
||||
trap - EXIT INT TERM
|
||||
continue
|
||||
fi
|
||||
size="$(wc -c <"$LOG_DIR/current.log")"
|
||||
if [ "$size" -ge "$LOG_LIMIT" ]; then
|
||||
mv -f "$LOG_DIR/current.log" "$LOG_DIR/previous.log"
|
||||
: >"$LOG_DIR/current.log"
|
||||
fi
|
||||
printf '%s\n' "$line" >>"$LOG_DIR/current.log"
|
||||
printf '%s\n' "$(( $(cat "$LOG_DIR/total") + $(printf '%s\n' "$line" | wc -c) ))" >"$LOG_DIR/total"
|
||||
log_unlock
|
||||
trap - EXIT INT TERM
|
||||
done
|
||||
@@ -110,6 +196,57 @@ log_clear() {
|
||||
log_reset_locked
|
||||
log_unlock
|
||||
}
|
||||
log_export() {
|
||||
local journal total previous current ack_id ack start available count clear_ack chunk
|
||||
log_lock || return 1
|
||||
log_maintain_locked
|
||||
log_cursor_locked
|
||||
journal="$(cat "$LOG_DIR/journal-id")"; total="$(cat "$LOG_DIR/total")"
|
||||
ack_id=''; ack=0
|
||||
if [ -s "$LOG_DIR/sync-ack" ]; then read -r ack_id ack <"$LOG_DIR/sync-ack"; fi
|
||||
[ "$ack_id" = "$journal" ] || ack=0
|
||||
case "$ack" in ''|*[!0-9]*) ack=0 ;; esac
|
||||
[ "$ack" -le "$total" ] || ack=0
|
||||
previous=0
|
||||
if [ -f "$LOG_DIR/previous.log" ]; then previous="$(wc -c <"$LOG_DIR/previous.log")"; exec 3<"$LOG_DIR/previous.log"; else exec 3</dev/null; fi
|
||||
current="$(wc -c <"$LOG_DIR/current.log")"; exec 4<"$LOG_DIR/current.log"
|
||||
start=$((total - previous - current)); [ "$ack" -le "$start" ] || start="$ack"
|
||||
available=$((total - start)); count="$available"; [ "$count" -le 65536 ] || count=65536
|
||||
clear_ack="$(cat "$LOG_DIR/sync-clear-ack" 2>/dev/null)"
|
||||
log_unlock
|
||||
chunk="$LOG_DIR/export.$$"
|
||||
trap 'rm -f "$chunk"; exec 3<&- 4<&-' EXIT
|
||||
: >"$chunk"
|
||||
if [ "$count" -gt 0 ]; then
|
||||
{ head -c "$previous" <&3; head -c "$current" <&4; } | tail -c "$available" | head -c "$count" >"$chunk"
|
||||
fi
|
||||
count="$(wc -c <"$chunk")"
|
||||
printf '{"journal_id":"%s","from":%s,"to":%s,"clear_ack":"%s","data":"' "$journal" "$start" "$((start + count))" "$clear_ack"
|
||||
base64 <"$chunk" | tr -d '\r\n'
|
||||
printf '"}\n'
|
||||
rm -f "$chunk"; exec 3<&- 4<&-; trap - EXIT
|
||||
}
|
||||
log_ack() {
|
||||
local journal offset clear_token
|
||||
journal="$1"; offset="$2"; clear_token="${3:-}"
|
||||
case "$journal$clear_token" in *[!a-zA-Z0-9._:-]*) return 1 ;; esac
|
||||
case "$offset" in ''|*[!0-9]*) return 1 ;; esac
|
||||
log_lock || return 1
|
||||
log_maintain_locked
|
||||
if [ -n "$clear_token" ] && [ "$(cat "$LOG_DIR/sync-clear-ack" 2>/dev/null)" != "$clear_token" ]; then
|
||||
log_reset_locked
|
||||
printf '%s\n' "$clear_token" >"$LOG_DIR/sync-clear-ack"
|
||||
elif [ "$(cat "$LOG_DIR/journal-id" 2>/dev/null)" = "$journal" ]; then
|
||||
printf '%s %s\n' "$journal" "$offset" >"$LOG_DIR/sync-ack"
|
||||
fi
|
||||
log_unlock
|
||||
}
|
||||
log_sync_loop() {
|
||||
while :; do
|
||||
/usr/sbin/owrt-remote logs-sync >/dev/null 2>&1
|
||||
sleep 3
|
||||
done
|
||||
}
|
||||
log_collect() {
|
||||
# These variables must remain visible to EXIT even after this function returns.
|
||||
log_init || return 1
|
||||
@@ -134,10 +271,16 @@ log_collect() {
|
||||
}
|
||||
|
||||
case "${1:-}" in
|
||||
check) log_init ;;
|
||||
collect) log_collect ;;
|
||||
read) log_read "${2:-}" ;;
|
||||
clear) log_clear ;;
|
||||
export) log_export ;;
|
||||
ack) log_ack "$2" "$3" "${4:-}" ;;
|
||||
sync) log_sync_loop ;;
|
||||
append) log_append ;;
|
||||
event) { printf '%s owrt-remote: %s\n' "$(date '+%Y-%m-%d %H:%M:%S')" "$2"; cat; } | log_append ;;
|
||||
event)
|
||||
case "${3:-ok}" in bad|error) level=ERROR ;; warn) level=WARN ;; *) level=OK ;; esac
|
||||
{ printf '%s owrt-remote: %s\n' "$(date '+%Y-%m-%d %H:%M:%S')" "$2"; cat; } | log_append "$level" ;;
|
||||
*) printf 'Usage: logs.sh collect|read [live]|clear|append|event MESSAGE\n' >&2; exit 2 ;;
|
||||
esac
|
||||
@@ -7,7 +7,8 @@ SECTION="main"
|
||||
XRAY_RELEASE_BASE_URL="${XRAY_RELEASE_BASE_URL:-https://github.com/XTLS/Xray-core/releases/latest/download}"
|
||||
|
||||
log() {
|
||||
printf '%s\n' "$*" >&2
|
||||
# procd already captures stderr. Use only logger for managed processes.
|
||||
[ "${OWRT_REMOTE_SERVICE_LOG:-0}" = 1 ] || printf '%s\n' "$*" >&2
|
||||
logger -t owrt-remote "$*" 2>/dev/null || true
|
||||
}
|
||||
|
||||
@@ -27,6 +28,7 @@ usage() {
|
||||
owrt-remote run
|
||||
owrt-remote heartbeat
|
||||
owrt-remote heartbeat-loop
|
||||
owrt-remote logs-sync
|
||||
owrt-remote network-diagnostics
|
||||
|
||||
Настройки лежат в /etc/config/owrtremote.
|
||||
@@ -559,7 +561,9 @@ render_client_config() {
|
||||
cat >"$out" <<EOF
|
||||
{
|
||||
"log": {
|
||||
"loglevel": "info"
|
||||
"access": "none",
|
||||
"error": "",
|
||||
"loglevel": "warning"
|
||||
},
|
||||
"inbounds": [],
|
||||
"outbounds": [
|
||||
@@ -758,6 +762,65 @@ post_json() {
|
||||
die "для heartbeat нужен uclient-fetch, wget или curl"
|
||||
}
|
||||
|
||||
global_logs_state() {
|
||||
local enabled xray
|
||||
enabled=false; xray=stopped
|
||||
truthy "$(uci_get enabled 0)" && enabled=true
|
||||
xray_running && xray=running
|
||||
printf '{"enabled":%s,"xray":"%s"}' "$enabled" "$xray"
|
||||
}
|
||||
|
||||
sync_global_logs() (
|
||||
local helper router_id batch file response endpoint base token journal offset clear_token rc sync_lock owner attempt
|
||||
helper="${OWRT_REMOTE_LOG_HELPER:-/usr/lib/owrt-remote/logs.sh}"
|
||||
[ -r "$helper" ] || return 0
|
||||
token="$(uci_get hub_token '')"; [ -n "$token" ] || return 0
|
||||
# The journal is independent of Remote's enabled flag and Xray lifecycle.
|
||||
sh "$helper" check || return 1
|
||||
sync_lock="${OWRT_REMOTE_LOG_DIR:-/tmp/owrt-remote-logs}/sync-lock"
|
||||
if ! mkdir "$sync_lock" 2>/dev/null; then
|
||||
# Give a sender time to write its PID, then recover an abandoned lock.
|
||||
for attempt in 1 2 3 4 5 6 7 8 9 10; do
|
||||
owner="$(cat "$sync_lock/pid" 2>/dev/null)"
|
||||
case "$owner" in ''|*[!0-9]*) sleep 0.1 ;; *) break ;; esac
|
||||
done
|
||||
owner="$(cat "$sync_lock/pid" 2>/dev/null)"
|
||||
case "$owner" in ''|*[!0-9]*) ;; *) kill -0 "$owner" 2>/dev/null && return 0 ;; esac
|
||||
rm -f "$sync_lock/pid"; rmdir "$sync_lock" 2>/dev/null || return 0
|
||||
mkdir "$sync_lock" 2>/dev/null || return 0
|
||||
fi
|
||||
printf '%s\n' "$$" >"$sync_lock/pid"
|
||||
file=''; response=''
|
||||
trap 'rm -f "$file" "$response" "$sync_lock/pid"; rmdir "$sync_lock" 2>/dev/null || true' EXIT
|
||||
trap 'exit 1' INT TERM
|
||||
if truthy "$(uci_get wan_direct 0)" && [ ! -s "$WAN_STATE/active-interface" ]; then wan_prepare || return 1; fi
|
||||
batch="$(sh "$helper" export)" || return 1
|
||||
router_id="$(safe_id "$(uci_get router_id main)")"
|
||||
# export verifies that this directory is on tmpfs; payloads also stay in RAM.
|
||||
umask 077
|
||||
file="${OWRT_REMOTE_LOG_DIR:-/tmp/owrt-remote-logs}/sync.$$"; response="$file.response"
|
||||
printf '{"id":%s,"batch":%s,"state":%s}\n' "$(json_string "$router_id")" "$batch" "$(global_logs_state)" >"$file"
|
||||
for endpoint in $(heartbeat_candidate_endpoints); do
|
||||
base="$(heartbeat_base_from_endpoint "$endpoint")"
|
||||
if post_json "$base/api/router-logs" "$token" "$file" >"$response" 2>/dev/null &&
|
||||
grep -Eq '"ok"[[:space:]]*:[[:space:]]*true' "$response"; then
|
||||
journal="$(jsonfilter -i "$response" -e '@.journal_id' 2>/dev/null)"
|
||||
offset="$(jsonfilter -i "$response" -e '@.offset' 2>/dev/null)"
|
||||
clear_token="$(jsonfilter -i "$response" -e '@.clear_request' 2>/dev/null)"
|
||||
sh "$helper" ack "$journal" "$offset" "$clear_token"
|
||||
rc=$?
|
||||
rm -f "$file" "$response"
|
||||
rm -f "$sync_lock/pid"; rmdir "$sync_lock" 2>/dev/null || true
|
||||
trap - EXIT INT TERM
|
||||
return "$rc"
|
||||
fi
|
||||
done
|
||||
rm -f "$file" "$response"
|
||||
rm -f "$sync_lock/pid"; rmdir "$sync_lock" 2>/dev/null || true
|
||||
trap - EXIT INT TERM
|
||||
return 1
|
||||
)
|
||||
|
||||
heartbeat_base_from_endpoint() {
|
||||
printf '%s' "${1%/api/heartbeat}"
|
||||
}
|
||||
@@ -1284,6 +1347,9 @@ case "$cmd" in
|
||||
heartbeat-loop)
|
||||
heartbeat_loop
|
||||
;;
|
||||
logs-sync)
|
||||
sync_global_logs
|
||||
;;
|
||||
*)
|
||||
usage >&2
|
||||
exit 2
|
||||
|
||||
@@ -133,7 +133,7 @@ set_result() {
|
||||
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
|
||||
printf '%s\n' "$RESULT_BODY" | sh "$LOG_HELPER" event "Панель: $RESULT_TITLE; результат=$RESULT_KIND" "$RESULT_KIND" >/dev/null 2>&1 || true
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -145,6 +145,11 @@ logs_response() {
|
||||
printf 'Сборщик логов не установлен. Установи локальный фикс целиком.\n'
|
||||
return
|
||||
fi
|
||||
if ! sh "$LOG_HELPER" check >/dev/null 2>&1; then
|
||||
printf 'Status: 503 Service Unavailable\r\nContent-Type: text/plain; charset=utf-8\r\nCache-Control: no-store\r\n\r\n'
|
||||
printf 'Журнал недоступен: для логов требуется ОЗУ (tmpfs). Запись на Flash запрещена.\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'
|
||||
@@ -359,6 +364,10 @@ run_action() {
|
||||
if [ "$rc" != "0" ]; then
|
||||
set_result "$RESULT_TITLE" "$(cat "$output")" "bad"
|
||||
fi
|
||||
# Deliver the completed stop result without keeping a mobile HTTP request open.
|
||||
if [ "$action" = stop ]; then
|
||||
( "$AGENT" logs-sync ) </dev/null >/dev/null 2>&1 &
|
||||
fi
|
||||
rm -f "$output"
|
||||
}
|
||||
|
||||
@@ -474,7 +483,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 v115</title>
|
||||
<title>OpenWrt Remote Hub v116</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}
|
||||
@@ -497,6 +506,7 @@ form{margin:0}.formgrid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr
|
||||
.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}
|
||||
.globalLogsLegend{display:flex;gap:8px 14px;flex-wrap:wrap;margin:0 0 12px;font-size:12px;font-weight:700}.globalLogLine{display:block}.globalLogOk{color:#86efac}.globalLogWarn{color:#fde68a}.globalLogError{color:#f87171}
|
||||
@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}}
|
||||
@@ -508,7 +518,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">v115</span></span></h1>
|
||||
<h1 class="appBanner"><span>OpenWrt Remote Hub <span class="appBannerVersion">v116</span></span></h1>
|
||||
</div>
|
||||
<div class="links">
|
||||
<a class="uiPill" href="https://t.me/kzolotarev95" target="_blank" rel="noopener noreferrer">Telegram</a>
|
||||
@@ -532,7 +542,8 @@ form{margin:0}.formgrid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr
|
||||
|
||||
<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>
|
||||
<blockquote class="globalLogsNote">Действия панели, изменения связи с Hub и WAN, предупреждения и ошибки Xray. Одинаковые события не дублируются. Журнал хранится только в ОЗУ, очищается после перезагрузки и каждые 24 часа. Максимум около 2 МБ. Ключи и пароли скрываются.</blockquote>
|
||||
<div class="globalLogsLegend" aria-label="Цвета журнала"><span class="globalLogOk">● Успешно</span><span class="globalLogWarn">● Предупреждение</span><span class="globalLogError">● Ошибка</span></div>
|
||||
<div class="actions">
|
||||
<a class="btn" href="?key=$(h "$key")&action=logs_download">Скачать логи</a>
|
||||
<button class="btn" id="globalLogsLive" type="button">Запустить в реальном времени</button>
|
||||
@@ -656,6 +667,34 @@ EOF
|
||||
var output = document.getElementById('globalLogsText');
|
||||
var status = document.getElementById('globalLogsStatus');
|
||||
var timer = null, controller = null, generation = 0, running = false;
|
||||
var renderedText = null;
|
||||
function lineTone(line) {
|
||||
if (/^\[ERROR\]/.test(line)) return 'globalLogError';
|
||||
if (/^\[WARN\]/.test(line)) return 'globalLogWarn';
|
||||
if (/^\[OK\]/.test(line)) return 'globalLogOk';
|
||||
var message = line.replace(/^.*?owrt-remote(?:\[\d+\])?:\s*/, '');
|
||||
if (/core: Xray .* started/i.test(message)) return 'globalLogOk';
|
||||
if (/\[error\]|ошибка|не удалось|результат=bad|failed|cannot |could not |error:|syntax error|permission denied|network is unreachable|connection (refused|reset)|timed out|not permitted|no selected wan|wan has no|wan direct requires|already used by another rule|does not belong to remote|не применилось|dns failed|crash loop/i.test(message)) return 'globalLogError';
|
||||
if (/\[warn(?:ing)?\]|предупреждение|результат=warn|retry|not ready|missing|не найден|postponed|dns unavailable|fallback|reconnecting|restarting|failover/i.test(message)) return 'globalLogWarn';
|
||||
return 'globalLogOk';
|
||||
}
|
||||
function renderLogs(text, empty) {
|
||||
if (renderedText === text && output.querySelector('.globalLogLine')) return;
|
||||
var atBottom = output.scrollHeight - output.clientHeight - output.scrollTop < 24;
|
||||
var previousTop = output.scrollTop;
|
||||
var fragment = document.createDocumentFragment();
|
||||
var lines = text ? text.replace(/\r\n/g, '\n').replace(/\n$/, '').split('\n') : [empty];
|
||||
lines.forEach(function(line) {
|
||||
var row = document.createElement('span');
|
||||
row.className = 'globalLogLine ' + lineTone(line);
|
||||
row.textContent = line || ' ';
|
||||
fragment.appendChild(row);
|
||||
});
|
||||
output.textContent = '';
|
||||
output.appendChild(fragment);
|
||||
renderedText = text;
|
||||
output.scrollTop = atBottom ? output.scrollHeight : previousTop;
|
||||
}
|
||||
function endpoint(action) {
|
||||
var url = new URL(window.location.href);
|
||||
url.searchParams.set('action', action);
|
||||
@@ -684,12 +723,7 @@ EOF
|
||||
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;
|
||||
}
|
||||
renderLogs(text, once ? 'Журнал пока пуст. Новые записи появятся после действий в панели или событий Remote. Нажми «Запустить в реальном времени», чтобы увидеть их.' : 'Журнал пуст. Новые события появятся автоматически.');
|
||||
status.textContent = (once ? 'Сохранённые записи' : 'Просмотр в реальном времени') + ' · обновлено ' + new Date().toLocaleTimeString() + ' · последние 64 КБ журнала' + (once ? '. Для автообновления нажми «Запустить в реальном времени».' : '');
|
||||
} catch (error) {
|
||||
if (current === generation && (running || once)) {
|
||||
|
||||
@@ -14,7 +14,7 @@ return view.extend({
|
||||
|
||||
if (!key) {
|
||||
return E('div', { 'class': 'cbi-map' }, [
|
||||
E('h2', {}, _('OpenWrt Remote Hub v115')),
|
||||
E('h2', {}, _('OpenWrt Remote Hub v116')),
|
||||
E('div', { 'class': 'alert-message warning' }, [
|
||||
_('Web key not found. Reinstall the module or create /etc/owrt-remote/web.key.')
|
||||
])
|
||||
@@ -34,7 +34,7 @@ return view.extend({
|
||||
}, 100);
|
||||
|
||||
return E('div', { 'class': 'cbi-map' }, [
|
||||
E('h2', {}, _('OpenWrt Remote Hub v115')),
|
||||
E('h2', {}, _('OpenWrt Remote Hub v116')),
|
||||
E('p', {}, _('Opening remote access panel...')),
|
||||
E('p', {}, [
|
||||
E('a', { 'class': 'btn cbi-button cbi-button-apply', 'href': url }, _('Open panel'))
|
||||
|
||||
Reference in new issue
Block a user