Add heartbeat Xray remote control and v121
This commit is contained in:
1 parent
e942ccfcd9
commit
6cf3ae7c0f
100 files changed
+1631
-218
No files matched your search
@@ -15,7 +15,7 @@ $RemoteScript = @'
|
||||
set -eu
|
||||
stage=/tmp/__UPLOAD_NAME__
|
||||
target=/opt/owrt-remote/owrt-remote-hub.py
|
||||
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-dashboard-layout-v120
|
||||
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-dashboard-layout-v121
|
||||
candidate=$target.new-__UPLOAD_NAME__
|
||||
changed=0
|
||||
|
||||
@@ -106,7 +106,7 @@ if [ "$healthy" -ne 1 ]; then
|
||||
exit 1
|
||||
fi
|
||||
cmp "$source_file" "$target"
|
||||
printf '\nBackup: %s\nDASHBOARD_LAYOUT_V120_%s_OK\n' "$backup" '__ACTION__'
|
||||
printf '\nBackup: %s\nDASHBOARD_LAYOUT_V121_%s_OK\n' "$backup" '__ACTION__'
|
||||
'@
|
||||
|
||||
$RemoteScript = $RemoteScript.Replace('__UPLOAD_NAME__', $UploadName).Replace('__ACTION__', $Action)
|
||||
|
||||
@@ -15,7 +15,7 @@ $RemoteScript = @'
|
||||
set -eu
|
||||
stage=/tmp/__UPLOAD_NAME__
|
||||
target=/opt/owrt-remote/owrt-remote-hub.py
|
||||
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-dashboard-menu-v120
|
||||
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-dashboard-menu-v121
|
||||
candidate=$target.new-__UPLOAD_NAME__
|
||||
changed=0
|
||||
|
||||
@@ -108,7 +108,7 @@ if [ "$healthy" -ne 1 ]; then
|
||||
exit 1
|
||||
fi
|
||||
cmp "$source_file" "$target"
|
||||
printf '\nBackup: %s\nDASHBOARD_MENU_V120_%s_OK\n' "$backup" '__ACTION__'
|
||||
printf '\nBackup: %s\nDASHBOARD_MENU_V121_%s_OK\n' "$backup" '__ACTION__'
|
||||
'@
|
||||
|
||||
$RemoteScript = $RemoteScript.Replace('__UPLOAD_NAME__', $UploadName).Replace('__ACTION__', $Action)
|
||||
|
||||
@@ -15,7 +15,7 @@ $RemoteScript = @'
|
||||
set -eu
|
||||
stage=/tmp/__UPLOAD_NAME__
|
||||
target=/opt/owrt-remote/owrt-remote-hub.py
|
||||
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-global-logs-ui-v120
|
||||
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-global-logs-ui-v121
|
||||
candidate=$target.new-__UPLOAD_NAME__
|
||||
changed=0
|
||||
|
||||
@@ -107,7 +107,7 @@ if [ "$healthy" -ne 1 ]; then
|
||||
exit 1
|
||||
fi
|
||||
cmp "$source_file" "$target"
|
||||
printf '\nBackup: %s\nGLOBAL_LOGS_VPS_V120_%s_OK\n' "$backup" '__ACTION__'
|
||||
printf '\nBackup: %s\nGLOBAL_LOGS_VPS_V121_%s_OK\n' "$backup" '__ACTION__'
|
||||
'@
|
||||
|
||||
$RemoteScript = $RemoteScript.Replace('__UPLOAD_NAME__', $UploadName).Replace('__ACTION__', $Action)
|
||||
|
||||
@@ -13,7 +13,7 @@ $RemoteScript = @'
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
stage=/tmp/__UPLOAD_NAME__
|
||||
backup=/root/owrt-remote-backup-before-global-logs-stop-v120
|
||||
backup=/root/owrt-remote-backup-before-global-logs-stop-v121
|
||||
items='cgi agent init logs.sh logs-init luci'
|
||||
changed=0
|
||||
phase=preflight
|
||||
@@ -104,7 +104,7 @@ if [ '__ACTION__' = Install ]; then
|
||||
command -v base64 >/dev/null
|
||||
command -v jsonfilter >/dev/null
|
||||
grep -F -q 'globalLogsToggle' "$stage/cgi"
|
||||
for item in cgi luci; do grep -F -q 'v120' "$stage/$item"; done
|
||||
for item in cgi luci; do grep -F -q 'v121' "$stage/$item"; done
|
||||
grep -F -q 'LOG_KEEP_SECONDS=86400' "$stage/logs.sh"
|
||||
grep -F -q 'log_sync_loop' "$stage/logs.sh"
|
||||
grep -F -q 'sync_global_logs' "$stage/agent"
|
||||
|
||||
@@ -6,7 +6,7 @@ param(
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$RepoRoot = Split-Path -Parent $PSScriptRoot
|
||||
$UploadName = 'owrt-group-colors-v120-' + [guid]::NewGuid().ToString('N')
|
||||
$UploadName = 'owrt-group-colors-v121-' + [guid]::NewGuid().ToString('N')
|
||||
$StageRoot = Join-Path ([System.IO.Path]::GetTempPath()) $UploadName
|
||||
$Utf8 = [System.Text.UTF8Encoding]::new($false)
|
||||
|
||||
@@ -15,7 +15,7 @@ $RemoteScript = @'
|
||||
set -eu
|
||||
stage=/tmp/__UPLOAD_NAME__
|
||||
target=/opt/owrt-remote/owrt-remote-hub.py
|
||||
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-group-colors-v120
|
||||
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-group-colors-v121
|
||||
candidate=$target.new-__UPLOAD_NAME__
|
||||
changed=0
|
||||
|
||||
@@ -57,7 +57,7 @@ if [ '__ACTION__' = Install ]; then
|
||||
from pathlib import Path
|
||||
import sys
|
||||
source = Path(sys.argv[1]).read_text(encoding='utf-8')
|
||||
required = ('v120', '#routerForm select option,#routerGroupFilter option', 'background-color:#221a34', 'id="backupDownload"', 'id="backupRestore"')
|
||||
required = ('v121', '#routerForm select option,#routerGroupFilter option', 'background-color:#221a34', 'id="backupDownload"', 'id="backupRestore"')
|
||||
if 'class="backupCmds"' in source:
|
||||
print('Old backup command instructions remain in candidate', file=sys.stderr)
|
||||
raise SystemExit(1)
|
||||
@@ -106,7 +106,7 @@ if [ "$healthy" -ne 1 ]; then
|
||||
exit 1
|
||||
fi
|
||||
cmp "$source_file" "$target"
|
||||
printf '\nBackup: %s\nGROUP_COLORS_V120_%s_OK\n' "$backup" '__ACTION__'
|
||||
printf '\nBackup: %s\nGROUP_COLORS_V121_%s_OK\n' "$backup" '__ACTION__'
|
||||
'@
|
||||
|
||||
$RemoteScript = $RemoteScript.Replace('__UPLOAD_NAME__', $UploadName).Replace('__ACTION__', $Action)
|
||||
|
||||
@@ -13,7 +13,7 @@ $RemoteScript = @'
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
stage=/tmp/__UPLOAD_NAME__
|
||||
backup=/root/owrt-remote-backup-before-heartbeat-redirect-v120
|
||||
backup=/root/owrt-remote-backup-before-heartbeat-redirect-v121
|
||||
agent=/usr/sbin/owrt-remote
|
||||
wan=/usr/lib/owrt-remote/wan.sh
|
||||
changed=0
|
||||
|
||||
@@ -17,7 +17,7 @@ $RemoteScript = @'
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
stage=/tmp/__UPLOAD_NAME__
|
||||
backup_dir=/root/owrt-remote-backup-before-heartbeat-transport-v120
|
||||
backup_dir=/root/owrt-remote-backup-before-heartbeat-transport-v121
|
||||
changed=0
|
||||
phase=preflight
|
||||
item_path() {
|
||||
|
||||
@@ -5,7 +5,7 @@ param(
|
||||
[string]$PinnedVpsHost = '193.233.82.38',
|
||||
[ValidatePattern('^[a-zA-Z0-9_-]+$')][string]$WanInterface = 'wan',
|
||||
[switch]$PreserveConnectionSettings,
|
||||
[ValidatePattern('^[a-zA-Z0-9_-]+$')][string]$BackupName = 'host-policy-v120',
|
||||
[ValidatePattern('^[a-zA-Z0-9_-]+$')][string]$BackupName = 'host-policy-v121',
|
||||
[switch]$PrepareOnly
|
||||
)
|
||||
|
||||
@@ -90,7 +90,7 @@ test -s "$config"
|
||||
if [ '__ACTION__' = Install ]; then
|
||||
for item in agent wan.sh cgi init; do test -s "$stage/$item"; sh -n "$stage/$item"; done
|
||||
test -s "$stage/luci"
|
||||
for item in cgi luci; do grep -F -q 'v120' "$stage/$item"; done
|
||||
for item in cgi luci; do grep -F -q 'v121' "$stage/$item"; done
|
||||
# curl is needed to preserve HTTPS SNI and bypass the local DNS/proxy.
|
||||
if ! command -v curl >/dev/null 2>&1; then
|
||||
if command -v opkg >/dev/null 2>&1; then opkg update && opkg install curl ca-bundle
|
||||
@@ -156,16 +156,16 @@ if [ '__ACTION__' = Install ]; then
|
||||
exit 1
|
||||
fi
|
||||
/usr/sbin/owrt-remote status
|
||||
grep -F -q 'v120' /www/cgi-bin/owrt-remote
|
||||
grep -F -q 'v120' /www/luci-static/resources/view/owrt_remote.js
|
||||
echo HOST_POLICY_ROUTER_V120_OK
|
||||
grep -F -q 'v121' /www/cgi-bin/owrt-remote
|
||||
grep -F -q 'v121' /www/luci-static/resources/view/owrt_remote.js
|
||||
echo HOST_POLICY_ROUTER_V121_OK
|
||||
else
|
||||
test -f "$backup/complete"
|
||||
save_files "$stage/previous"
|
||||
changed=1
|
||||
restore_files "$backup"
|
||||
/usr/sbin/owrt-remote status
|
||||
echo HOST_POLICY_ROUTER_V120_ROLLBACK_OK
|
||||
echo HOST_POLICY_ROUTER_V121_ROLLBACK_OK
|
||||
fi
|
||||
'@
|
||||
} else {
|
||||
@@ -180,7 +180,7 @@ fi
|
||||
set -eu
|
||||
stage=/tmp/__UPLOAD_NAME__
|
||||
target=/opt/owrt-remote/owrt-remote-hub.py
|
||||
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-host-policy-v120
|
||||
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-host-policy-v121
|
||||
changed=0
|
||||
cleanup() {
|
||||
code=$?
|
||||
@@ -200,7 +200,7 @@ test -s "$target"
|
||||
python_bin=/opt/owrt-remote/venv/bin/python
|
||||
[ -x "$python_bin" ] || python_bin=python3
|
||||
if [ '__ACTION__' = Install ]; then
|
||||
grep -F -q 'v120' "$stage/hub.py"
|
||||
grep -F -q 'v121' "$stage/hub.py"
|
||||
"$python_bin" -m py_compile "$stage/hub.py"
|
||||
OWRT_HOST_POLICY_HUB_SOURCE="$stage/hub.py" "$python_bin" "$stage/test_host_policy.py" HostPolicyTests -v
|
||||
OWRT_RESOURCE_HUB_SOURCE="$stage/hub.py" "$python_bin" "$stage/resources.py" -v
|
||||
@@ -226,7 +226,7 @@ for attempt in 1 2 3 4 5 6 7 8 9 10; do
|
||||
done
|
||||
test "$healthy" = 1
|
||||
cmp "$candidate" "$target"
|
||||
printf '\nHOST_POLICY_VPS_V120_%s_OK\n' '__ACTION__'
|
||||
printf '\nHOST_POLICY_VPS_V121_%s_OK\n' '__ACTION__'
|
||||
'@
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ $RemoteScript = @'
|
||||
set -eu
|
||||
stage=/tmp/__UPLOAD_NAME__
|
||||
target=/opt/owrt-remote/owrt-remote-hub.py
|
||||
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-hub-design-v120
|
||||
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-hub-design-v121
|
||||
candidate=$target.new-__UPLOAD_NAME__
|
||||
changed=0
|
||||
|
||||
@@ -130,7 +130,7 @@ if [ "$healthy" -ne 1 ]; then
|
||||
fi
|
||||
cat "$stage/health-check"
|
||||
cmp "$source_file" "$target"
|
||||
printf '\nBackup: %s\nHUB_DESIGN_V120_%s_OK\n' "$backup" '__ACTION__'
|
||||
printf '\nBackup: %s\nHUB_DESIGN_V121_%s_OK\n' "$backup" '__ACTION__'
|
||||
if [ '__ACTION__' = Install ]; then
|
||||
echo 'Refresh the Hub page and open Effects to choose the panel design.'
|
||||
echo 'This fix is LOCAL. The panel update button can replace it with the published repository build.'
|
||||
|
||||
@@ -15,7 +15,7 @@ $RemoteScript = @'
|
||||
set -eu
|
||||
stage=/tmp/__UPLOAD_NAME__
|
||||
target=/opt/owrt-remote/owrt-remote-hub.py
|
||||
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-hub-self-update-v120
|
||||
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-hub-self-update-v121
|
||||
candidate=$target.new-__UPLOAD_NAME__
|
||||
changed=0
|
||||
|
||||
@@ -107,7 +107,7 @@ if [ "$healthy" -ne 1 ]; then
|
||||
exit 1
|
||||
fi
|
||||
cmp "$source_file" "$target"
|
||||
printf '\nBackup: %s\nHUB_SELF_UPDATE_V120_%s_OK\n' "$backup" '__ACTION__'
|
||||
printf '\nBackup: %s\nHUB_SELF_UPDATE_V121_%s_OK\n' "$backup" '__ACTION__'
|
||||
'@
|
||||
|
||||
$RemoteScript = $RemoteScript.Replace('__UPLOAD_NAME__', $UploadName).Replace('__ACTION__', $Action)
|
||||
|
||||
@@ -34,7 +34,7 @@ if ($Target -eq 'Router') {
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
stage=/tmp/__UPLOAD_NAME__
|
||||
backup=/root/owrt-remote-backup-before-hub-url-v120
|
||||
backup=/root/owrt-remote-backup-before-hub-url-v121
|
||||
chmod 700 "$stage"
|
||||
config=/etc/config/owrtremote
|
||||
changed=0
|
||||
@@ -99,7 +99,7 @@ if [ '__ACTION__' = Install ]; then
|
||||
grep -F -q 'heartbeat_set_url_if_changed()' "$stage/agent"
|
||||
grep -F -q 'reason=https-downgrade' "$stage/agent"
|
||||
for item in agent wan.sh; do grep -F -q -- '--post301' "$stage/$item"; done
|
||||
for item in cgi luci; do grep -F -q 'v120' "$stage/$item"; done
|
||||
for item in cgi luci; do grep -F -q 'v121' "$stage/$item"; done
|
||||
if [ ! -e "$backup" ]; then
|
||||
save_files "$stage/retained-backup"
|
||||
mv "$stage/retained-backup" "$backup"
|
||||
@@ -138,7 +138,7 @@ else
|
||||
changed=1
|
||||
restore_files "$backup"
|
||||
fi
|
||||
printf '\nBackup: %s\nHUB_URL_ROUTER_V120_%s_OK\n' "$backup" '__ACTION__'
|
||||
printf '\nBackup: %s\nHUB_URL_ROUTER_V121_%s_OK\n' "$backup" '__ACTION__'
|
||||
'@
|
||||
} else {
|
||||
$Payloads = @{
|
||||
@@ -152,7 +152,7 @@ set -eu
|
||||
stage=/tmp/__UPLOAD_NAME__
|
||||
target=/opt/owrt-remote/owrt-remote-hub.py
|
||||
chmod 700 "$stage"
|
||||
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-hub-url-v120
|
||||
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-hub-url-v121
|
||||
candidate=$target.new-__UPLOAD_NAME__
|
||||
changed=0
|
||||
cleanup() {
|
||||
@@ -174,7 +174,7 @@ python_bin=/opt/owrt-remote/venv/bin/python
|
||||
[ -x "$python_bin" ] || python_bin=python3
|
||||
if [ '__ACTION__' = Install ]; then
|
||||
grep -F -q 'def router_hub_origins(' "$stage/hub.py"
|
||||
grep -F -q 'v120' "$stage/hub.py"
|
||||
grep -F -q 'v121' "$stage/hub.py"
|
||||
"$python_bin" -m py_compile "$stage/hub.py"
|
||||
OWRT_HOST_POLICY_HUB_SOURCE="$stage/hub.py" "$python_bin" "$stage/host_policy.py" HostPolicyTests -v
|
||||
OWRT_RESOURCE_HUB_SOURCE="$stage/hub.py" "$python_bin" "$stage/resources.py" IntegrationTests -v
|
||||
@@ -198,7 +198,7 @@ for attempt in 1 2 3 4 5 6 7 8 9 10; do
|
||||
done
|
||||
test "$healthy" = 1
|
||||
cmp "$source_file" "$target"
|
||||
printf '\nBackup: %s\nHUB_URL_VPS_V120_%s_OK\n' "$backup" '__ACTION__'
|
||||
printf '\nBackup: %s\nHUB_URL_VPS_V121_%s_OK\n' "$backup" '__ACTION__'
|
||||
'@
|
||||
}
|
||||
$RemoteScript = $RemoteScript.Replace('__UPLOAD_NAME__', $UploadName).Replace('__ACTION__', $Action).Replace('__HUB_URL__', $HubUrl)
|
||||
|
||||
@@ -17,7 +17,7 @@ $RemoteScript = @'
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
stage=/tmp/__UPLOAD_NAME__
|
||||
backup_dir=/root/owrt-remote-backup-before-log-collector-v120
|
||||
backup_dir=/root/owrt-remote-backup-before-log-collector-v121
|
||||
changed=0
|
||||
phase=preflight
|
||||
items='logs.sh logs-init'
|
||||
|
||||
@@ -14,7 +14,7 @@ $RemoteScript = @'
|
||||
set -eu
|
||||
stage=/tmp/__UPLOAD_NAME__
|
||||
target=/opt/owrt-remote/owrt-remote-hub.py
|
||||
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-online-status-v120
|
||||
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-online-status-v121
|
||||
candidate=$target.new-__UPLOAD_NAME__
|
||||
changed=0
|
||||
cleanup() {
|
||||
@@ -59,7 +59,7 @@ for attempt in 1 2 3 4 5 6 7 8 9 10; do
|
||||
done
|
||||
test "$healthy" = 1
|
||||
cmp "$source_file" "$target"
|
||||
printf '\nBackup: %s\nONLINE_STATUS_V120_%s_OK\n' "$backup" '__ACTION__'
|
||||
printf '\nBackup: %s\nONLINE_STATUS_V121_%s_OK\n' "$backup" '__ACTION__'
|
||||
'@
|
||||
$RemoteScript = $RemoteScript.Replace('__UPLOAD_NAME__', $UploadName).Replace('__ACTION__', $Action)
|
||||
try {
|
||||
|
||||
@@ -15,7 +15,7 @@ $RemoteScript = @'
|
||||
set -eu
|
||||
stage=/tmp/__UPLOAD_NAME__
|
||||
target=/opt/owrt-remote/owrt-remote-hub.py
|
||||
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-password-logout-v120
|
||||
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-password-logout-v121
|
||||
candidate=$target.new-__UPLOAD_NAME__
|
||||
changed=0
|
||||
|
||||
@@ -105,7 +105,7 @@ if [ "$healthy" -ne 1 ]; then
|
||||
exit 1
|
||||
fi
|
||||
cmp "$source_file" "$target"
|
||||
printf '\nBackup: %s\nPASSWORD_LOGOUT_V120_%s_OK\n' "$backup" '__ACTION__'
|
||||
printf '\nBackup: %s\nPASSWORD_LOGOUT_V121_%s_OK\n' "$backup" '__ACTION__'
|
||||
'@
|
||||
|
||||
$RemoteScript = $RemoteScript.Replace('__UPLOAD_NAME__', $UploadName).Replace('__ACTION__', $Action)
|
||||
|
||||
@@ -15,7 +15,7 @@ $RemoteScript = @'
|
||||
set -eu
|
||||
stage=/tmp/__UPLOAD_NAME__
|
||||
target=/opt/owrt-remote/owrt-remote-hub.py
|
||||
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-persistent-logs-sync-v120
|
||||
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-persistent-logs-sync-v121
|
||||
candidate=$target.new-__UPLOAD_NAME__
|
||||
changed=0
|
||||
|
||||
@@ -144,7 +144,7 @@ if [ "$healthy" -ne 1 ]; then
|
||||
exit 1
|
||||
fi
|
||||
cmp "$source_file" "$target"
|
||||
printf '\nBackup: %s\nPERSISTENT_LOGS_VPS_V120_%s_OK\n' "$backup" '__ACTION__'
|
||||
printf '\nBackup: %s\nPERSISTENT_LOGS_VPS_V121_%s_OK\n' "$backup" '__ACTION__'
|
||||
'@
|
||||
|
||||
$RemoteScript = $RemoteScript.Replace('__UPLOAD_NAME__', $UploadName).Replace('__ACTION__', $Action)
|
||||
|
||||
@@ -13,7 +13,7 @@ $RemoteScript = @'
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
stage=/tmp/__UPLOAD_NAME__
|
||||
backup=/root/owrt-remote-backup-before-persistent-logs-v120
|
||||
backup=/root/owrt-remote-backup-before-persistent-logs-v121
|
||||
items='cgi agent logs.sh logs-init luci'
|
||||
changed=0
|
||||
phase=preflight
|
||||
@@ -106,7 +106,7 @@ if [ '__ACTION__' = Install ]; then
|
||||
exit 1
|
||||
fi
|
||||
grep -F -q 'globalLogsToggle' "$stage/cgi"
|
||||
for item in cgi luci; do grep -F -q 'v120' "$stage/$item"; done
|
||||
for item in cgi luci; do grep -F -q 'v121' "$stage/$item"; done
|
||||
grep -F -q 'LOG_BUFFER_LIMIT=16384' "$stage/logs.sh"
|
||||
grep -F -q 'LOG_KEEP_SECONDS=86400' "$stage/logs.sh"
|
||||
grep -F -q 'log_sync_loop' "$stage/logs.sh"
|
||||
|
||||
@@ -17,8 +17,8 @@ if ($Action -eq 'Install') {
|
||||
set -Eeuo pipefail
|
||||
stage=/tmp/__UPLOAD_NAME__
|
||||
target=/opt/owrt-remote/owrt-remote-hub.py
|
||||
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-recaptcha-v3-v120
|
||||
captcha_backup=/opt/owrt-remote/captcha-before-recaptcha-v3-v120.json
|
||||
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-recaptcha-v3-v121
|
||||
captcha_backup=/opt/owrt-remote/captcha-before-recaptcha-v3-v121.json
|
||||
candidate=$target.new-__UPLOAD_NAME__
|
||||
changed=0
|
||||
cleanup() {
|
||||
@@ -45,7 +45,7 @@ if [ ! -x "$python_bin" ]; then python_bin=python3; fi
|
||||
import ast, pathlib, sys
|
||||
source = pathlib.Path(sys.argv[1]).read_text(encoding='utf-8')
|
||||
tree = ast.parse(source)
|
||||
assert 'v120' in source
|
||||
assert 'v121' in source
|
||||
assert 'v108' not in source
|
||||
assert 'CAPTCHA_MODE_RECAPTCHA_V3' in source
|
||||
assert 'prepareLoginRecaptcha' in source
|
||||
@@ -88,7 +88,7 @@ pid=$(systemctl show owrt-remote -p MainPID --value)
|
||||
test "$pid" -gt 0
|
||||
printf 'PID=%s FD=%s\n' "$pid" "$(find /proc/$pid/fd -maxdepth 1 -type l | wc -l)"
|
||||
systemctl --no-pager --full status owrt-remote | sed -n '1,16p'
|
||||
echo RECAPTCHA_V3_V120_OK
|
||||
echo RECAPTCHA_V3_V121_OK
|
||||
'@
|
||||
} elseif ($Action -eq 'Rollback') {
|
||||
$RemoteScript = @'
|
||||
@@ -96,8 +96,8 @@ echo RECAPTCHA_V3_V120_OK
|
||||
set -Eeuo pipefail
|
||||
stage=/tmp/__UPLOAD_NAME__
|
||||
target=/opt/owrt-remote/owrt-remote-hub.py
|
||||
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-recaptcha-v3-v120
|
||||
captcha_backup=/opt/owrt-remote/captcha-before-recaptcha-v3-v120.json
|
||||
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-recaptcha-v3-v121
|
||||
captcha_backup=/opt/owrt-remote/captcha-before-recaptcha-v3-v121.json
|
||||
candidate=$target.rollback-__UPLOAD_NAME__
|
||||
changed=0
|
||||
restore_captcha() {
|
||||
|
||||
@@ -15,7 +15,7 @@ set -eu
|
||||
|
||||
stage=/tmp/__UPLOAD_NAME__
|
||||
target=/opt/owrt-remote/owrt-remote-hub.py
|
||||
backup=/root/owrt-remote-backup-before-request-load-v120
|
||||
backup=/root/owrt-remote-backup-before-request-load-v121
|
||||
policy=/etc/nginx/conf.d/owrt-remote-log-policy.conf
|
||||
journal=/etc/systemd/journald.conf.d/owrt-remote-limits.conf
|
||||
logrotate=/etc/logrotate.d/owrt-remote
|
||||
@@ -184,7 +184,7 @@ PY
|
||||
done
|
||||
[ "$healthy" = 1 ]
|
||||
|
||||
printf '\nBackup: %s\nREQUEST_LOAD_FIX_V120_%s_OK\n' "$backup" '__ACTION__'
|
||||
printf '\nBackup: %s\nREQUEST_LOAD_FIX_V121_%s_OK\n' "$backup" '__ACTION__'
|
||||
'@
|
||||
|
||||
$RemoteScript = $RemoteScript.Replace('__UPLOAD_NAME__', $UploadName).Replace('__ACTION__', $Action)
|
||||
|
||||
@@ -18,7 +18,7 @@ if ($Action -eq 'Install') {
|
||||
set -Eeuo pipefail
|
||||
stage=/tmp/__UPLOAD_NAME__
|
||||
target=/opt/owrt-remote/owrt-remote-hub.py
|
||||
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-resource-fix-v120
|
||||
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-resource-fix-v121
|
||||
candidate=$target.new-__UPLOAD_NAME__
|
||||
changed=0
|
||||
cleanup() {
|
||||
@@ -45,7 +45,7 @@ if [ ! -x "$python_bin" ]; then python_bin=python3; fi
|
||||
import ast, pathlib, sys
|
||||
source = pathlib.Path(sys.argv[1]).read_text(encoding='utf-8')
|
||||
tree = ast.parse(source)
|
||||
assert 'v120' in source
|
||||
assert 'v121' in source
|
||||
assert 'v108' not in source
|
||||
factory = next(node for node in tree.body if isinstance(node, ast.FunctionDef) and node.name == 'connect')
|
||||
assert any(isinstance(item, ast.Name) and item.id == 'contextmanager' for item in factory.decorator_list)
|
||||
@@ -78,7 +78,7 @@ pid=$(systemctl show owrt-remote -p MainPID --value)
|
||||
test "$pid" -gt 0
|
||||
printf 'PID=%s FD=%s\n' "$pid" "$(find /proc/$pid/fd -maxdepth 1 -type l | wc -l)"
|
||||
systemctl --no-pager --full status owrt-remote | sed -n '1,16p'
|
||||
echo RESOURCE_FIX_V120_OK
|
||||
echo RESOURCE_FIX_V121_OK
|
||||
'@
|
||||
} elseif ($Action -eq 'Rollback') {
|
||||
$RemoteScript = @'
|
||||
@@ -86,7 +86,7 @@ echo RESOURCE_FIX_V120_OK
|
||||
set -Eeuo pipefail
|
||||
stage=/tmp/__UPLOAD_NAME__
|
||||
target=/opt/owrt-remote/owrt-remote-hub.py
|
||||
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-resource-fix-v120
|
||||
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-resource-fix-v121
|
||||
candidate=$target.rollback-__UPLOAD_NAME__
|
||||
changed=0
|
||||
cleanup() {
|
||||
|
||||
@@ -15,7 +15,7 @@ $RemoteScript = @'
|
||||
set -eu
|
||||
stage=/tmp/__UPLOAD_NAME__
|
||||
target=/opt/owrt-remote/owrt-remote-hub.py
|
||||
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-router-card-ui-v120
|
||||
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-router-card-ui-v121
|
||||
candidate=$target.new-__UPLOAD_NAME__
|
||||
changed=0
|
||||
|
||||
@@ -106,7 +106,7 @@ if [ "$healthy" -ne 1 ]; then
|
||||
exit 1
|
||||
fi
|
||||
cmp "$source_file" "$target"
|
||||
printf '\nBackup: %s\nROUTER_CARD_UI_V120_%s_OK\n' "$backup" '__ACTION__'
|
||||
printf '\nBackup: %s\nROUTER_CARD_UI_V121_%s_OK\n' "$backup" '__ACTION__'
|
||||
'@
|
||||
|
||||
$RemoteScript = $RemoteScript.Replace('__UPLOAD_NAME__', $UploadName).Replace('__ACTION__', $Action)
|
||||
|
||||
@@ -15,7 +15,7 @@ set -eu
|
||||
stage=/tmp/__UPLOAD_NAME__
|
||||
cgi=/www/cgi-bin/owrt-remote
|
||||
effects=/www/luci-static/resources/owrt_remote_effects.js
|
||||
backup=/root/owrt-remote-backup-before-router-effects-v120
|
||||
backup=/root/owrt-remote-backup-before-router-effects-v121
|
||||
changed=0
|
||||
|
||||
restore_file() {
|
||||
@@ -85,7 +85,7 @@ if [ '__ACTION__' = Install ]; then
|
||||
grep -F -q 'id="routerEffectsPanel"' "$cgi"
|
||||
grep -F -q 'function initHubAppearance()' "$effects"
|
||||
fi
|
||||
printf '\nBackup: %s\nROUTER_EFFECTS_V120_%s_OK\n' "$backup" '__ACTION__'
|
||||
printf '\nBackup: %s\nROUTER_EFFECTS_V121_%s_OK\n' "$backup" '__ACTION__'
|
||||
'@
|
||||
|
||||
$RemoteScript = $RemoteScript.Replace('__UPLOAD_NAME__', $UploadName).Replace('__ACTION__', $Action)
|
||||
|
||||
@@ -15,7 +15,7 @@ $RemoteScript = @'
|
||||
set -eu
|
||||
stage=/tmp/__UPLOAD_NAME__
|
||||
target=/opt/owrt-remote/owrt-remote-hub.py
|
||||
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-router-name-fix-v120
|
||||
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-router-name-fix-v121
|
||||
candidate=$target.new-__UPLOAD_NAME__
|
||||
changed=0
|
||||
|
||||
@@ -135,7 +135,7 @@ if [ "$healthy" -ne 1 ]; then
|
||||
fi
|
||||
cat "$stage/health-check"
|
||||
cmp "$source_file" "$target"
|
||||
printf '\nBackup: %s\nROUTER_NAME_FIX_V120_%s_OK\n' "$backup" '__ACTION__'
|
||||
printf '\nBackup: %s\nROUTER_NAME_FIX_V121_%s_OK\n' "$backup" '__ACTION__'
|
||||
if [ '__ACTION__' = Install ]; then
|
||||
echo 'Refresh the Hub and router updates tabs to check the renamed routers.'
|
||||
echo 'This fix is LOCAL. The panel update button can replace it with the published repository build.'
|
||||
|
||||
@@ -15,7 +15,7 @@ $RemoteScript = @'
|
||||
set -eu
|
||||
stage=/tmp/__UPLOAD_NAME__
|
||||
target=/opt/owrt-remote/owrt-remote-hub.py
|
||||
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-router-reboot-all-v120
|
||||
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-router-reboot-all-v121
|
||||
candidate=$target.new-__UPLOAD_NAME__
|
||||
changed=0
|
||||
|
||||
@@ -125,7 +125,7 @@ if [ "$healthy" -ne 1 ]; then
|
||||
exit 1
|
||||
fi
|
||||
cmp "$source_file" "$target"
|
||||
printf '\nBackup: %s\nROUTER_UPDATES_V120_%s_OK\n' "$backup" '__ACTION__'
|
||||
printf '\nBackup: %s\nROUTER_UPDATES_V121_%s_OK\n' "$backup" '__ACTION__'
|
||||
'@
|
||||
|
||||
$RemoteScript = $RemoteScript.Replace('__UPLOAD_NAME__', $UploadName).Replace('__ACTION__', $Action)
|
||||
|
||||
@@ -15,7 +15,7 @@ $RemoteScript = @'
|
||||
set -eu
|
||||
stage=/tmp/__UPLOAD_NAME__
|
||||
target=/opt/owrt-remote/owrt-remote-hub.py
|
||||
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-update-status-ui-v120
|
||||
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-update-status-ui-v121
|
||||
candidate=$target.new-__UPLOAD_NAME__
|
||||
changed=0
|
||||
|
||||
@@ -139,7 +139,7 @@ if [ "$healthy" -ne 1 ]; then
|
||||
fi
|
||||
cat "$stage/health-check"
|
||||
cmp "$source_file" "$target"
|
||||
printf '\nBackup: %s\nUPDATE_STATUS_UI_V120_%s_OK\n' "$backup" '__ACTION__'
|
||||
printf '\nBackup: %s\nUPDATE_STATUS_UI_V121_%s_OK\n' "$backup" '__ACTION__'
|
||||
if [ '__ACTION__' = Install ]; then
|
||||
echo 'Reload the Hub page (Ctrl+F5) to load the new UI.'
|
||||
echo 'This fix is LOCAL. The panel update button can replace it with the published repository build.'
|
||||
|
||||
@@ -7,7 +7,7 @@ param(
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$RepoRoot = Split-Path -Parent $PSScriptRoot
|
||||
$UploadName = 'owrt-version-v120-' + [guid]::NewGuid().ToString('N')
|
||||
$UploadName = 'owrt-version-v121-' + [guid]::NewGuid().ToString('N')
|
||||
$StageRoot = Join-Path ([System.IO.Path]::GetTempPath()) $UploadName
|
||||
$Utf8 = [System.Text.UTF8Encoding]::new($false)
|
||||
|
||||
@@ -16,7 +16,7 @@ $RemoteScript = @'
|
||||
set -eu
|
||||
stage=/tmp/__UPLOAD_NAME__
|
||||
target=/opt/owrt-remote/owrt-remote-hub.py
|
||||
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-v120
|
||||
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-v121
|
||||
candidate=$target.new-__UPLOAD_NAME__
|
||||
changed=0
|
||||
|
||||
@@ -58,9 +58,9 @@ if [ '__ACTION__' = Install ]; then
|
||||
from pathlib import Path
|
||||
import sys
|
||||
source = Path(sys.argv[1]).read_text(encoding='utf-8')
|
||||
required = ('v120', 'def hub_update_require_version(', 'def hub_update_older_version(',
|
||||
required = ('v121', 'def hub_update_require_version(', 'def hub_update_older_version(',
|
||||
"else if (state.checked && !state.checking) message('');")
|
||||
if 'v' + str(120 - 1) in source:
|
||||
if 'v' + str(121 - 1) in source:
|
||||
print('Old UI version remains in candidate', file=sys.stderr)
|
||||
raise SystemExit(1)
|
||||
missing = [marker for marker in required if marker not in source]
|
||||
@@ -133,14 +133,14 @@ if [ "$healthy" -ne 1 ]; then
|
||||
fi
|
||||
cat "$stage/health-check"
|
||||
cmp "$source_file" "$target"
|
||||
printf '\nBackup: %s\nHUB_V120_%s_OK\n' "$backup" '__ACTION__'
|
||||
printf '\nBackup: %s\nHUB_V121_%s_OK\n' "$backup" '__ACTION__'
|
||||
'@
|
||||
|
||||
$RouterScript = @'
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
stage=/tmp/__UPLOAD_NAME__
|
||||
backup=/root/owrt-remote-backup-before-v120
|
||||
backup=/root/owrt-remote-backup-before-v121
|
||||
cgi=/www/cgi-bin/owrt-remote
|
||||
luci=/www/luci-static/resources/view/owrt_remote.js
|
||||
changed=0
|
||||
@@ -164,9 +164,9 @@ test -s "$cgi"
|
||||
test -s "$luci"
|
||||
if [ '__ACTION__' = Install ]; then
|
||||
sh -n "$stage/cgi"
|
||||
grep -F -q 'v120' "$stage/cgi"
|
||||
grep -F -q 'v120' "$stage/luci"
|
||||
if grep -F -q "v$((120 - 1))" "$stage/cgi" "$stage/luci"; then
|
||||
grep -F -q 'v121' "$stage/cgi"
|
||||
grep -F -q 'v121' "$stage/luci"
|
||||
if grep -F -q "v$((121 - 1))" "$stage/cgi" "$stage/luci"; then
|
||||
echo 'Old UI version remains in candidate.' >&2
|
||||
exit 1
|
||||
fi
|
||||
@@ -199,7 +199,7 @@ cmp "$source_dir/cgi" "$cgi"
|
||||
cmp "$source_dir/luci" "$luci"
|
||||
[ ! -x /etc/init.d/rpcd ] || /etc/init.d/rpcd restart || true
|
||||
[ ! -x /etc/init.d/uhttpd ] || /etc/init.d/uhttpd reload || true
|
||||
printf '\nBackup: %s\nROUTER_V120_%s_OK\n' "$backup" '__ACTION__'
|
||||
printf '\nBackup: %s\nROUTER_V121_%s_OK\n' "$backup" '__ACTION__'
|
||||
'@
|
||||
|
||||
if ($PSCmdlet.ParameterSetName -eq 'Router') {
|
||||
@@ -240,7 +240,7 @@ try {
|
||||
if ($LASTEXITCODE -ne 0) { throw 'Upload failed. Target was not changed.' }
|
||||
& ssh -T -o ConnectTimeout=10 $TargetMachine "sh /tmp/$UploadName/run.sh"
|
||||
if ($LASTEXITCODE -ne 0) { throw "$Action failed. See the output above; success was not confirmed." }
|
||||
Write-Host "Version v120 $Action finished successfully. Refresh the panel."
|
||||
Write-Host "Version v121 $Action finished successfully. Refresh the panel."
|
||||
}
|
||||
finally {
|
||||
if (-not $PrepareOnly) {
|
||||
@@ -15,7 +15,7 @@ $RemoteScript = @'
|
||||
set -eu
|
||||
stage=/tmp/__UPLOAD_NAME__
|
||||
target=/opt/owrt-remote/owrt-remote-hub.py
|
||||
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-vps-resources-live-v120
|
||||
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-vps-resources-live-v121
|
||||
candidate=$target.new-__UPLOAD_NAME__
|
||||
changed=0
|
||||
|
||||
@@ -107,7 +107,7 @@ if [ "$healthy" -ne 1 ]; then
|
||||
exit 1
|
||||
fi
|
||||
cmp "$source_file" "$target"
|
||||
printf '\nBackup: %s\nVPS_RESOURCES_LIVE_V120_%s_OK\n' "$backup" '__ACTION__'
|
||||
printf '\nBackup: %s\nVPS_RESOURCES_LIVE_V121_%s_OK\n' "$backup" '__ACTION__'
|
||||
'@
|
||||
|
||||
$RemoteScript = $RemoteScript.Replace('__UPLOAD_NAME__', $UploadName).Replace('__ACTION__', $Action)
|
||||
|
||||
@@ -14,7 +14,7 @@ $RemoteScript = @'
|
||||
set -eu
|
||||
stage=/tmp/__UPLOAD_NAME__
|
||||
target=/opt/owrt-remote/owrt-remote-hub.py
|
||||
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-vps-widgets-v120
|
||||
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-vps-widgets-v121
|
||||
candidate=$target.new-__UPLOAD_NAME__
|
||||
changed=0
|
||||
cleanup() {
|
||||
@@ -37,7 +37,7 @@ python_bin=/opt/owrt-remote/venv/bin/python
|
||||
[ -x "$python_bin" ] || python_bin=python3
|
||||
if [ '__ACTION__' = Install ]; then
|
||||
test -s "$stage/hub.py"
|
||||
grep -F -q 'v120' "$stage/hub.py"
|
||||
grep -F -q 'v121' "$stage/hub.py"
|
||||
"$python_bin" -m py_compile "$stage/hub.py"
|
||||
OWRT_VPS_WIDGETS_HUB_SOURCE="$stage/hub.py" "$python_bin" "$stage/tests.py" -v
|
||||
if [ ! -e "$backup" ]; then cp -p "$target" "$backup"; fi
|
||||
@@ -67,7 +67,7 @@ if [ '__ACTION__' = Install ]; then
|
||||
code=$(curl -sS --max-time 5 -o "$stage/response.json" -w '%{http_code}' http://127.0.0.1:8088/api/vps/resources)
|
||||
test "$code" = 401
|
||||
fi
|
||||
printf '\nVPS_WIDGETS_V120_%s_OK\n' '__ACTION__'
|
||||
printf '\nVPS_WIDGETS_V121_%s_OK\n' '__ACTION__'
|
||||
'@
|
||||
$RemoteScript = $RemoteScript.Replace('__UPLOAD_NAME__', $UploadName).Replace('__ACTION__', $Action)
|
||||
try {
|
||||
|
||||
@@ -14,7 +14,7 @@ $RemoteScript = @'
|
||||
set -eu
|
||||
stage=/tmp/__UPLOAD_NAME__
|
||||
target=/usr/lib/owrt-remote/wan.sh
|
||||
backup_dir=/root/owrt-remote-backup-before-wan-dns-v120
|
||||
backup_dir=/root/owrt-remote-backup-before-wan-dns-v121
|
||||
changed=0
|
||||
phase=preflight
|
||||
heartbeat_pid() {
|
||||
|
||||
@@ -20,7 +20,7 @@ $RemoteScript = @'
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
stage=/tmp/__UPLOAD_NAME__
|
||||
backup=/root/owrt-remote-backup-before-wan-multi-v120
|
||||
backup=/root/owrt-remote-backup-before-wan-multi-v121
|
||||
config=/etc/config/owrtremote
|
||||
changed=0
|
||||
item_path() {
|
||||
@@ -81,7 +81,7 @@ test -s "$config"
|
||||
if [ '__ACTION__' = Install ]; then
|
||||
for item in agent wan.sh cgi hotplug; do test -s "$stage/$item"; sh -n "$stage/$item"; done
|
||||
test -s "$stage/luci"
|
||||
for item in cgi luci; do grep -F -q 'v120' "$stage/$item"; done
|
||||
for item in cgi luci; do grep -F -q 'v121' "$stage/$item"; done
|
||||
grep -F -q 'wan_interface_picker' "$stage/cgi"
|
||||
grep -F -q 'wan_select_interface()' "$stage/wan.sh"
|
||||
grep -F -q 'wan_reconcile_xray()' "$stage/agent"
|
||||
|
||||
@@ -17,7 +17,7 @@ $RemoteScript = @'
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
stage=/tmp/__UPLOAD_NAME__
|
||||
backup_dir=/root/owrt-remote-backup-before-wan-recovery-v120
|
||||
backup_dir=/root/owrt-remote-backup-before-wan-recovery-v121
|
||||
changed=0
|
||||
phase=preflight
|
||||
item_path() {
|
||||
|
||||
@@ -17,7 +17,7 @@ $RemoteScript = @'
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
stage=/tmp/__UPLOAD_NAME__
|
||||
backup=/root/owrt-remote-backup-before-wan-stability-v120
|
||||
backup=/root/owrt-remote-backup-before-wan-stability-v121
|
||||
config=/etc/config/owrtremote
|
||||
changed=0
|
||||
fail() {
|
||||
|
||||
@@ -15,7 +15,7 @@ $RemoteScript = @'
|
||||
set -eu
|
||||
stage=/tmp/__UPLOAD_NAME__
|
||||
target=/opt/owrt-remote/owrt-remote-hub.py
|
||||
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-web-push-v120
|
||||
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-web-push-v121
|
||||
candidate=$target.new-__UPLOAD_NAME__
|
||||
changed=0
|
||||
|
||||
@@ -72,7 +72,7 @@ for attempt in 1 2 3 4 5 6 7 8 9 10; do
|
||||
done
|
||||
test "$healthy" = 1
|
||||
cmp "$source_file" "$target"
|
||||
printf '\nBackup: %s\nWEB_PUSH_V120_%s_OK\n' "$backup" '__ACTION__'
|
||||
printf '\nBackup: %s\nWEB_PUSH_V121_%s_OK\n' "$backup" '__ACTION__'
|
||||
'@
|
||||
|
||||
$RemoteScript = $RemoteScript.Replace('__UPLOAD_NAME__', $UploadName).Replace('__ACTION__', $Action)
|
||||
|
||||
@@ -16,7 +16,7 @@ $RemoteScript = @'
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
stage=/tmp/__UPLOAD_NAME__
|
||||
backup_dir=/root/owrt-remote-backup-before-xray-apk-v120
|
||||
backup_dir=/root/owrt-remote-backup-before-xray-apk-v121
|
||||
key_file=/etc/owrt-remote/web.key
|
||||
key_candidate=$key_file.new-__UPLOAD_NAME__
|
||||
changed=0
|
||||
|
||||
@@ -14,7 +14,7 @@ $RemoteScript = @'
|
||||
set -eu
|
||||
stage=/tmp/__UPLOAD_NAME__
|
||||
target=/www/cgi-bin/owrt-remote
|
||||
backup_dir=/root/owrt-remote-backup-before-xray-apply-v120
|
||||
backup_dir=/root/owrt-remote-backup-before-xray-apply-v121
|
||||
backup=$backup_dir/owrt-remote
|
||||
candidate=$target.new-__UPLOAD_NAME__
|
||||
changed=0
|
||||
|
||||
@@ -14,7 +14,7 @@ $RemoteScript = @'
|
||||
set -eu
|
||||
stage=/tmp/__UPLOAD_NAME__
|
||||
target=/usr/sbin/owrt-remote
|
||||
backup_dir=/root/owrt-remote-backup-before-xray-boot-v120
|
||||
backup_dir=/root/owrt-remote-backup-before-xray-boot-v121
|
||||
changed=0
|
||||
phase=preflight
|
||||
heartbeat_pid() {
|
||||
|
||||
@@ -17,7 +17,7 @@ $RemoteScript = @'
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
stage=/tmp/__UPLOAD_NAME__
|
||||
backup_dir=/root/owrt-remote-backup-before-xray-compat-v120
|
||||
backup_dir=/root/owrt-remote-backup-before-xray-compat-v121
|
||||
changed=0
|
||||
phase=preflight
|
||||
item_path() {
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
param(
|
||||
[Parameter(Mandatory = $true)][string]$Vps,
|
||||
[ValidateSet('Install', 'Rollback')][string]$Action = 'Install',
|
||||
[switch]$PrepareOnly
|
||||
)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
& (Join-Path $PSScriptRoot 'deploy-xray-control.ps1') -Vps $Vps -Action $Action -BackupName 'xray-control-ui' -PrepareOnly:$PrepareOnly
|
||||
@@ -0,0 +1,218 @@
|
||||
param(
|
||||
[Parameter(Mandatory = $true, ParameterSetName = 'Vps')][string]$Vps,
|
||||
[Parameter(Mandatory = $true, ParameterSetName = 'Router')][string]$Router,
|
||||
[ValidateSet('Install', 'Rollback')][string]$Action = 'Install',
|
||||
[ValidateSet('xray-control', 'xray-control-ui')][string]$BackupName = 'xray-control',
|
||||
[switch]$PrepareOnly
|
||||
)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$RepoRoot = Split-Path -Parent $PSScriptRoot
|
||||
$UploadName = 'owrt-xray-control-' + [guid]::NewGuid().ToString('N')
|
||||
$StageRoot = Join-Path ([System.IO.Path]::GetTempPath()) $UploadName
|
||||
$Utf8 = [System.Text.UTF8Encoding]::new($false)
|
||||
$TargetKind = $PSCmdlet.ParameterSetName
|
||||
$Destination = if ($TargetKind -eq 'Vps') { $Vps } else { $Router }
|
||||
|
||||
$RemoteScript = @'
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
stage=/tmp/__UPLOAD_NAME__
|
||||
kind=__KIND__
|
||||
action=__ACTION__
|
||||
backup=/root/owrt-remote-backup-before-__BACKUP_NAME__-v121
|
||||
changed=0
|
||||
step=preflight
|
||||
|
||||
if [ "$kind" = Vps ]; then
|
||||
names=hub.py
|
||||
else
|
||||
names='agent control.sh init'
|
||||
fi
|
||||
target() {
|
||||
case "$1" in
|
||||
hub.py) echo /opt/owrt-remote/owrt-remote-hub.py ;;
|
||||
agent) echo /usr/sbin/owrt-remote ;;
|
||||
control.sh) echo /usr/lib/owrt-remote/control.sh ;;
|
||||
init) echo /etc/init.d/owrt-remote ;;
|
||||
esac
|
||||
}
|
||||
snapshot() {
|
||||
folder="$1"
|
||||
mkdir -p "$folder"
|
||||
for name in $names; do
|
||||
path="$(target "$name")"
|
||||
if [ -e "$path" ]; then cp -p "$path" "$folder/$name"; else : >"$folder/$name.absent"; fi
|
||||
done
|
||||
printf '%s\n' "$kind" >"$folder/complete"
|
||||
}
|
||||
apply_files() {
|
||||
folder="$1"
|
||||
for name in $names; do
|
||||
path="$(target "$name")"
|
||||
if [ -e "$folder/$name.absent" ]; then
|
||||
rm -f "$path"
|
||||
else
|
||||
test -s "$folder/$name"
|
||||
mkdir -p "$(dirname "$path")"
|
||||
cp "$folder/$name" "$path.new-__UPLOAD_NAME__"
|
||||
if [ "$name" = control.sh ]; then chmod 0644 "$path.new-__UPLOAD_NAME__"; else chmod 0755 "$path.new-__UPLOAD_NAME__"; fi
|
||||
mv -f "$path.new-__UPLOAD_NAME__" "$path"
|
||||
fi
|
||||
done
|
||||
}
|
||||
restart() {
|
||||
if [ "$kind" = Vps ]; then systemctl restart owrt-remote; else /etc/init.d/owrt-remote restart; fi
|
||||
}
|
||||
cleanup() {
|
||||
code=$?
|
||||
trap - EXIT
|
||||
set +e
|
||||
if [ "$code" -ne 0 ]; then echo "Failed during $step (rc=$code)." >&2; fi
|
||||
if [ "$code" -ne 0 ] && [ "$kind" = Router ]; then diagnose_router || true; fi
|
||||
if [ "$code" -ne 0 ] && [ "$changed" = 1 ]; then
|
||||
echo 'Deployment failed; restoring files from before this attempt.' >&2
|
||||
apply_files "$stage/previous" && restart || true
|
||||
fi
|
||||
if [ "$code" -ne 0 ] && [ "$kind" = Vps ]; then journalctl -u owrt-remote -n 35 --no-pager >&2 || true; fi
|
||||
for name in $names; do path="$(target "$name")"; rm -f "$path.new-__UPLOAD_NAME__"; done
|
||||
rm -rf "$stage"
|
||||
exit "$code"
|
||||
}
|
||||
diagnose_router() {
|
||||
[ "$kind" = Router ] || return 0
|
||||
echo 'Router deployment diagnostics:' >&2
|
||||
echo "stage=$stage action=$action" >&2
|
||||
for command_name in jsonfilter ubus timeout busybox; do
|
||||
if command -v "$command_name" >/dev/null 2>&1; then
|
||||
echo "command $command_name=$(command -v "$command_name")" >&2
|
||||
else
|
||||
echo "command $command_name=missing" >&2
|
||||
fi
|
||||
done
|
||||
echo 'owrt-remote service:' >&2
|
||||
ubus call service list '{"name":"owrt-remote"}' >&2 || true
|
||||
echo 'recent owrt-remote log:' >&2
|
||||
logread -e owrt-remote 2>/dev/null | tail -n 80 >&2 || true
|
||||
}
|
||||
fail_router() {
|
||||
echo "Router deployment error: $*" >&2
|
||||
exit 1
|
||||
}
|
||||
trap cleanup EXIT
|
||||
trap 'exit 1' INT TERM
|
||||
|
||||
if [ "$action" = Install ]; then
|
||||
if [ "$kind" = Vps ]; then
|
||||
python_bin=/opt/owrt-remote/venv/bin/python
|
||||
[ -x "$python_bin" ] || python_bin=python3
|
||||
"$python_bin" -m py_compile "$stage/hub.py"
|
||||
"$python_bin" - "$stage/hub.py" <<'PY'
|
||||
import pathlib, sys
|
||||
source = pathlib.Path(sys.argv[1]).read_text(encoding='utf-8')
|
||||
for marker in ('def xray_control_exchange(', 'def router_xray_control_html(', 'X-Xray-Control-CSRF', 'router_xray_commands'):
|
||||
if marker not in source: raise SystemExit('Candidate missing: ' + marker)
|
||||
print('Hub candidate validated')
|
||||
PY
|
||||
else
|
||||
sh -n "$stage/agent" || fail_router 'agent shell syntax check failed'
|
||||
sh -n "$stage/control.sh" || fail_router 'control.sh shell syntax check failed'
|
||||
sh -n "$stage/init" || fail_router 'init shell syntax check failed'
|
||||
command -v jsonfilter >/dev/null 2>&1 || fail_router 'jsonfilter is missing'
|
||||
command -v ubus >/dev/null 2>&1 || fail_router 'ubus is missing'
|
||||
# The agent has a bounded shell fallback when the optional BusyBox
|
||||
# timeout applet is absent, so this is informational rather than a
|
||||
# reason to reject an otherwise valid OpenWrt installation.
|
||||
if command -v timeout >/dev/null 2>&1; then
|
||||
echo 'Router preflight: timeout applet available' >&2
|
||||
elif command -v busybox >/dev/null 2>&1 && busybox timeout 45 true >/dev/null 2>&1; then
|
||||
echo 'Router preflight: BusyBox timeout applet available' >&2
|
||||
else
|
||||
echo 'Router preflight: timeout applet unavailable; agent shell timeout fallback will be used' >&2
|
||||
fi
|
||||
grep -Fq xray_control_dispatch "$stage/agent" || fail_router 'agent does not contain xray_control_dispatch'
|
||||
grep -Fq xray_control_worker "$stage/control.sh" || fail_router 'control.sh does not contain xray_control_worker'
|
||||
fi
|
||||
step=backup
|
||||
if [ ! -e "$backup/complete" ]; then
|
||||
test ! -e "$backup" || { echo "Incomplete backup already exists: $backup" >&2; exit 1; }
|
||||
snapshot "$backup"
|
||||
fi
|
||||
test "$(cat "$backup/complete")" = "$kind"
|
||||
source_dir="$stage"
|
||||
else
|
||||
step=backup
|
||||
test "$(cat "$backup/complete" 2>/dev/null)" = "$kind" || { echo "No complete backup: $backup. Nothing changed." >&2; exit 1; }
|
||||
source_dir="$backup"
|
||||
fi
|
||||
for name in $names; do test -s "$source_dir/$name" || test -e "$source_dir/$name.absent"; done
|
||||
snapshot "$stage/previous"
|
||||
changed=1
|
||||
step=apply-files
|
||||
apply_files "$source_dir"
|
||||
step=restart
|
||||
restart
|
||||
|
||||
step=verify-health
|
||||
if [ "$kind" = Vps ]; then
|
||||
python_bin=/opt/owrt-remote/venv/bin/python
|
||||
[ -x "$python_bin" ] || python_bin=python3
|
||||
"$python_bin" - <<'PY'
|
||||
import hashlib, json, pathlib, time, urllib.request
|
||||
expected = hashlib.sha256(pathlib.Path('/opt/owrt-remote/owrt-remote-hub.py').read_bytes()).hexdigest()
|
||||
opener = urllib.request.build_opener(urllib.request.ProxyHandler({}))
|
||||
for attempt in range(20):
|
||||
try:
|
||||
with opener.open('http://127.0.0.1:8088/health?panel-update=1', timeout=3) as response:
|
||||
data = json.load(response)
|
||||
if data.get('ok') and data.get('revision') == expected: break
|
||||
except Exception: pass
|
||||
time.sleep(1)
|
||||
else: raise SystemExit('Running Hub revision/health was not confirmed')
|
||||
print('Running Hub revision verified: ' + expected)
|
||||
PY
|
||||
else
|
||||
healthy=0
|
||||
for attempt in 1 2 3 4 5 6 7 8 9 10; do
|
||||
state="$(ubus call service list '{"name":"owrt-remote"}' 2>/dev/null || true)"
|
||||
if [ "$(printf '%s' "$state" | jsonfilter -e '@["owrt-remote"].instances.heartbeat.running')" = true ]; then healthy=1; break; fi
|
||||
sleep 1
|
||||
done
|
||||
[ "$healthy" = 1 ] || fail_router 'Heartbeat instance did not start; deployment is being rolled back.'
|
||||
fi
|
||||
step=verify-files
|
||||
for name in $names; do
|
||||
path="$(target "$name")"
|
||||
if [ -e "$source_dir/$name.absent" ]; then test ! -e "$path"; else cmp "$source_dir/$name" "$path"; fi
|
||||
done
|
||||
printf '\nBackup: %s\nXRAY_CONTROL_%s_%s_OK\n' "$backup" "$kind" "$action"
|
||||
'@
|
||||
|
||||
try {
|
||||
[System.IO.Directory]::CreateDirectory($StageRoot) | Out-Null
|
||||
$RemoteScript = $RemoteScript.Replace('__UPLOAD_NAME__', $UploadName).Replace('__KIND__', $TargetKind).Replace('__ACTION__', $Action).Replace('__BACKUP_NAME__', $BackupName)
|
||||
[System.IO.File]::WriteAllText((Join-Path $StageRoot 'run.sh'), $RemoteScript.Replace("`r`n", "`n") + "`n", $Utf8)
|
||||
if ($Action -eq 'Install') {
|
||||
$Sources = if ($TargetKind -eq 'Vps') {
|
||||
@{ 'hub.py' = 'vps\owrt-remote-hub.py' }
|
||||
} else {
|
||||
@{ 'agent' = 'files\usr\sbin\owrt-remote'; 'control.sh' = 'files\usr\lib\owrt-remote\control.sh'; 'init' = 'files\etc\init.d\owrt-remote' }
|
||||
}
|
||||
foreach ($Entry in $Sources.GetEnumerator()) {
|
||||
$Content = [System.IO.File]::ReadAllText((Join-Path $RepoRoot $Entry.Value)).Replace("`r`n", "`n")
|
||||
[System.IO.File]::WriteAllText((Join-Path $StageRoot $Entry.Key), $Content, $Utf8)
|
||||
}
|
||||
}
|
||||
if ($PrepareOnly) { Write-Host "Prepared only: $StageRoot"; return }
|
||||
& scp -O -o ConnectTimeout=20 -r -- $StageRoot "${Destination}:/tmp/"
|
||||
if ($LASTEXITCODE -ne 0) { throw 'Upload failed. Target was not changed.' }
|
||||
& ssh -T -o ConnectTimeout=20 -o ServerAliveInterval=15 $Destination "sh /tmp/$UploadName/run.sh"
|
||||
if ($LASTEXITCODE -ne 0) { throw "$Action failed. Success was not confirmed; see output above." }
|
||||
Write-Host "Xray remote control $TargetKind $Action finished successfully."
|
||||
} finally {
|
||||
if (-not $PrepareOnly -and (Test-Path -LiteralPath $StageRoot)) {
|
||||
$Resolved = [System.IO.Path]::GetFullPath($StageRoot)
|
||||
$Expected = [System.IO.Path]::GetFullPath((Join-Path ([System.IO.Path]::GetTempPath()) $UploadName))
|
||||
if ($Resolved -eq $Expected) { Remove-Item -LiteralPath $Resolved -Recurse -Force }
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@ $RemoteScript = @'
|
||||
set -eu
|
||||
stage=/tmp/__UPLOAD_NAME__
|
||||
target=/www/cgi-bin/owrt-remote
|
||||
backup_dir=/root/owrt-remote-backup-before-xray-mobile-v120
|
||||
backup_dir=/root/owrt-remote-backup-before-xray-mobile-v121
|
||||
backup=$backup_dir/owrt-remote
|
||||
candidate=$target.new-__UPLOAD_NAME__
|
||||
changed=0
|
||||
|
||||
@@ -17,7 +17,7 @@ $RemoteScript = @'
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
stage=/tmp/__UPLOAD_NAME__
|
||||
backup_dir=/root/owrt-remote-backup-before-xray-reverse-v120
|
||||
backup_dir=/root/owrt-remote-backup-before-xray-reverse-v121
|
||||
changed=0
|
||||
restart_attempted=0
|
||||
phase=preflight
|
||||
|
||||
@@ -15,7 +15,7 @@ $RemoteScript = @'
|
||||
set -eu
|
||||
stage=/tmp/__UPLOAD_NAME__
|
||||
target=/opt/owrt-remote/owrt-remote-hub.py
|
||||
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-xray-reverse-v120
|
||||
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-xray-reverse-v121
|
||||
candidate=$target.new-__UPLOAD_NAME__
|
||||
changed=0
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ $RemoteScript = @'
|
||||
set -eu
|
||||
stage=/tmp/__UPLOAD_NAME__
|
||||
target=/usr/sbin/owrt-remote
|
||||
backup_dir=/root/owrt-remote-backup-before-xray-source-v120
|
||||
backup_dir=/root/owrt-remote-backup-before-xray-source-v121
|
||||
runtime=/tmp/owrt-xray/xray
|
||||
changed=0
|
||||
phase=preflight
|
||||
|
||||
@@ -17,7 +17,7 @@ $RemoteScript = @'
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
stage=/tmp/__UPLOAD_NAME__
|
||||
backup_dir=/root/owrt-remote-backup-before-xray-validation-v120
|
||||
backup_dir=/root/owrt-remote-backup-before-xray-validation-v121
|
||||
changed=0
|
||||
phase=preflight
|
||||
item_path() {
|
||||
|
||||
+288
-4
@@ -3623,6 +3623,19 @@ def init_db(conn):
|
||||
journal_id text not null default '', cursor integer not null default 0,
|
||||
updated_at integer not null default 0, last_sync integer not null default 0,
|
||||
clear_request text not null default '')''')
|
||||
conn.execute('''create table if not exists router_xray_commands (
|
||||
id text primary key,
|
||||
router_id text not null,
|
||||
action text not null,
|
||||
status text not null default 'queued',
|
||||
result text not null default '',
|
||||
created_at integer not null,
|
||||
started_at integer not null default 0,
|
||||
completed_at integer not null default 0,
|
||||
delivered_at integer not null default 0
|
||||
)''')
|
||||
conn.execute('create index if not exists router_xray_commands_router_idx on router_xray_commands(router_id, created_at)')
|
||||
ensure_column(conn, 'router_xray_commands', 'hidden', 'integer not null default 0')
|
||||
ensure_column(conn, 'router_logs', 'state_json', "text not null default '{}'")
|
||||
ensure_column(conn, 'router_logs', 'state_at', 'integer not null default 0')
|
||||
ensure_column(conn, "routers", "custom_name", "text not null default ''")
|
||||
@@ -4226,6 +4239,120 @@ def upsert_router(conn, values):
|
||||
return get_router(conn, router_id)
|
||||
|
||||
|
||||
XRAY_CONTROL_ACTIONS = {'start': 'Запустить', 'stop': 'Остановить', 'restart': 'Перезапустить'}
|
||||
XRAY_CONTROL_TIMEOUT_SECONDS = 180
|
||||
XRAY_CONTROL_EXECUTION_SECONDS = 45
|
||||
|
||||
|
||||
def xray_control_audit(conn, router_id, message, level='OK'):
|
||||
conn.execute('insert or ignore into router_logs(router_id) values (?)', (router_id,))
|
||||
raw = bytes(conn.execute('select content from router_logs where router_id=?', (router_id,)).fetchone()[0])
|
||||
raw = (raw + f'[{level}] {iso_time(now_ts())} Hub: Remote Xray: {message}\n'.encode())[-ROUTER_LOG_MAX_BYTES:]
|
||||
conn.execute('update router_logs set content=?, updated_at=? where router_id=?', (raw, now_ts(), router_id))
|
||||
|
||||
|
||||
def xray_control_expire(conn, router_id):
|
||||
ts = now_ts()
|
||||
query = "select * from router_xray_commands where router_id=? and status in ('queued','delivered','running') and created_at < ?"
|
||||
if not conn.execute(query, (router_id, ts - XRAY_CONTROL_TIMEOUT_SECONDS)).fetchone():
|
||||
return
|
||||
# Most UI polls stay read-only. Serialize expiry only when a command is actually overdue.
|
||||
conn.execute('update routers set last_seen=last_seen where id=?', (router_id,))
|
||||
rows = conn.execute(query, (router_id, ts - XRAY_CONTROL_TIMEOUT_SECONDS)).fetchall()
|
||||
for row in rows:
|
||||
if ts - row['created_at'] <= XRAY_CONTROL_TIMEOUT_SECONDS:
|
||||
continue
|
||||
message = ('Команда не доставлена: агент не вышел на связь за 3 минуты. Команда отменена.'
|
||||
if not row['delivered_at'] else
|
||||
'Результат не подтверждён: агент не прислал итог за 3 минуты. Проверь журнал и текущий статус Xray.')
|
||||
status = 'expired' if not row['delivered_at'] else 'unconfirmed'
|
||||
conn.execute('update router_xray_commands set status=?, result=?, completed_at=? where id=?', (status, message, ts, row['id']))
|
||||
xray_control_audit(conn, router_id, message, 'WARN')
|
||||
|
||||
|
||||
def xray_control_enqueue(conn, router_id, action, request_id):
|
||||
if not isinstance(action, str) or action not in XRAY_CONTROL_ACTIONS or not re.fullmatch(r'[a-f0-9]{32}', str(request_id or '')):
|
||||
raise ValueError('Недопустимая команда или идентификатор запроса.')
|
||||
# Acquire the DB writer before checking the queue; concurrent tabs cannot enqueue two operations.
|
||||
conn.execute('update routers set last_seen=last_seen where id=?', (router_id,))
|
||||
row = get_active_router(conn, router_id)
|
||||
if not row:
|
||||
raise ValueError('Роутер не найден.')
|
||||
previous = conn.execute('select * from router_xray_commands where id=?', (request_id,)).fetchone()
|
||||
if previous:
|
||||
if previous['router_id'] != router_id or previous['action'] != action:
|
||||
raise ValueError('Этот идентификатор уже использован другой командой.')
|
||||
return
|
||||
if router_reported_status(row).get('xray_control') != 1:
|
||||
raise ValueError('Сначала обнови агент на этом роутере: управление через Heartbeat ещё не поддерживается.')
|
||||
xray_control_expire(conn, router_id)
|
||||
if conn.execute("select 1 from router_xray_commands where router_id=? and status in ('queued','delivered','running')", (router_id,)).fetchone():
|
||||
raise ValueError('Предыдущая команда ещё выполняется или ожидает Heartbeat.')
|
||||
conn.execute('insert into router_xray_commands(id,router_id,action,created_at) values (?,?,?,?)', (request_id, router_id, action, now_ts()))
|
||||
conn.execute('delete from router_xray_commands where router_id=? and id not in (select id from router_xray_commands where router_id=? order by created_at desc,rowid desc limit 100)', (router_id, router_id))
|
||||
xray_control_audit(conn, router_id, f'{XRAY_CONTROL_ACTIONS[action]} Xray: команда {request_id[:8]} поставлена в очередь.')
|
||||
|
||||
|
||||
def xray_control_exchange(conn, router_id, payload):
|
||||
conn.execute('update routers set last_seen=last_seen where id=?', (router_id,))
|
||||
result = payload.get('xray_control_result')
|
||||
if isinstance(result, dict):
|
||||
command = conn.execute('select * from router_xray_commands where id=? and router_id=?',
|
||||
(str(result.get('id') or ''), router_id)).fetchone()
|
||||
state, rc, xray = result.get('status'), result.get('rc'), result.get('xray')
|
||||
if (command and not command['hidden'] and command['delivered_at'] and command['action'] == result.get('action')
|
||||
and command['status'] in {'delivered', 'running', 'unconfirmed'}
|
||||
and state in {'running', 'succeeded', 'failed', 'interrupted'}
|
||||
and not (command['status'] == 'unconfirmed' and state == 'running')
|
||||
and type(rc) is int and 0 <= rc <= 255 and xray in {'running', 'stopped'}):
|
||||
if state == 'succeeded' and (rc != 0 or xray != ('stopped' if command['action'] == 'stop' else 'running')):
|
||||
state = 'failed'
|
||||
message = str(result.get('message') or '')[:1500]
|
||||
message = redact_router_log_bytes(message.encode()).decode('utf-8', 'replace')
|
||||
if state != command['status']:
|
||||
conn.execute('update router_xray_commands set status=?,result=?,started_at=case when started_at=0 then ? else started_at end,completed_at=? where id=?',
|
||||
(state, message, now_ts(), 0 if state == 'running' else now_ts(), command['id']))
|
||||
xray_control_audit(conn, router_id, f'{XRAY_CONTROL_ACTIONS[command["action"]]} Xray: {message} (rc={rc}, Xray={xray}).',
|
||||
'OK' if state in {'running', 'succeeded'} else 'ERROR')
|
||||
xray_control_expire(conn, router_id)
|
||||
if payload.get('xray_control') != 1:
|
||||
return None
|
||||
row = conn.execute("select * from router_xray_commands where router_id=? and status in ('queued','delivered') order by created_at limit 1", (router_id,)).fetchone()
|
||||
if not row:
|
||||
return None
|
||||
conn.execute("update router_xray_commands set status='delivered',delivered_at=case when delivered_at=0 then ? else delivered_at end where id=?", (now_ts(), row['id']))
|
||||
return {'id': row['id'], 'action': row['action']}
|
||||
|
||||
|
||||
def xray_control_clear_history(conn, router_id):
|
||||
# Keep bounded ID tombstones for retry protection, but erase completed output.
|
||||
# Active commands must remain visible and deliverable even from another tab.
|
||||
conn.execute('update routers set last_seen=last_seen where id=?', (router_id,))
|
||||
if not get_active_router(conn, router_id):
|
||||
raise ValueError('Роутер не найден.')
|
||||
xray_control_expire(conn, router_id)
|
||||
conn.execute("update router_xray_commands set hidden=1,result='' where router_id=? and status not in ('queued','delivered','running')",
|
||||
(router_id,))
|
||||
|
||||
|
||||
def xray_control_snapshot(conn, router_id):
|
||||
row = get_active_router(conn, router_id)
|
||||
if not row:
|
||||
raise ValueError('Роутер не найден.')
|
||||
xray_control_expire(conn, router_id)
|
||||
router = row_to_router(row)
|
||||
try:
|
||||
interval = int(router['status'].get('heartbeat_interval') or 30)
|
||||
except (TypeError, ValueError):
|
||||
interval = 30
|
||||
return {'ok': True, 'router_id': router_id, 'name': router['name'], 'online': router['online'],
|
||||
'last_seen': router['last_seen'], 'xray': router['status'].get('xray', 'unknown'),
|
||||
'supported': router['status'].get('xray_control') == 1,
|
||||
'server_time': now_ts(), 'heartbeat_interval': min(max(interval, 10), 3600),
|
||||
'command_timeout_seconds': XRAY_CONTROL_TIMEOUT_SECONDS, 'execution_timeout_seconds': XRAY_CONTROL_EXECUTION_SECONDS,
|
||||
'history': [dict(item) for item in conn.execute('select * from router_xray_commands where router_id=? and hidden=0 order by created_at desc,rowid desc limit 30', (router_id,))]}
|
||||
|
||||
|
||||
def heartbeat(conn, payload):
|
||||
router_id = clean_router_id(payload.get("id"))
|
||||
row = get_router(conn, router_id)
|
||||
@@ -6299,7 +6426,7 @@ input,select{{min-width:0;border:1px solid var(--line);border-radius:8px;padding
|
||||
<div class="brand">
|
||||
<div class="desktopHeader">
|
||||
<div class="desktopHeaderTop">
|
||||
<h1 class="appBanner"><span>OpenWrt Remote Hub <span class="appBannerVersion">v120</span></span></h1>
|
||||
<h1 class="appBanner"><span>OpenWrt Remote Hub <span class="appBannerVersion">v121</span></span></h1>
|
||||
<button class="badge hubUpdateButton" data-hub-update type="button" {'hidden' if not is_owner else ''}>Проверить обновление панели</button>
|
||||
<div class="routerSearchDock" id="routerSearchDock">
|
||||
<button class="routerSearchToggle" id="routerSearchToggle" type="button" aria-expanded="false" aria-controls="routerSearchPanel" data-active="false">
|
||||
@@ -6638,7 +6765,7 @@ input,select{{min-width:0;border:1px solid var(--line);border-radius:8px;padding
|
||||
</div>
|
||||
{vps_resource_widgets_html(mobile=True, resources=vps_resources)}
|
||||
<div class="mobileSearchDock" id="mobileHubUpdateDock">
|
||||
<span class="mobileSearchVersion">v120</span>
|
||||
<span class="mobileSearchVersion">v121</span>
|
||||
<button class="badge hubUpdateButton" data-hub-update type="button" {'hidden' if not is_owner else ''}>Проверить обновление панели</button>
|
||||
</div>
|
||||
<div class="mobileSearchDock" id="mobileSeasonDock" aria-label="Зимние эффекты">
|
||||
@@ -8310,6 +8437,7 @@ function render(list) {{
|
||||
${{sshButton}}
|
||||
${{wolButton}}
|
||||
${{logsButton}}
|
||||
${{permissions.manage ? `<a class="btn" href="/router/${{encodeURIComponent(r.id)}}/xray-control" target="_blank" rel="noopener noreferrer">Remote управление Xray</a>` : ''}}
|
||||
${{permissions.config ? `<a class="btn" href="${{escapeAttr(r.config_url)}}">OpenWrt config</a>` : '<span class="btn disabled">OpenWrt config</span>'}}
|
||||
${{permissions.delete ? `<button class="btn" data-delete="${{escapeAttr(r.id)}}">Удалить</button>` : '<span class="btn disabled">Удалить</span>'}}
|
||||
</div>
|
||||
@@ -8534,6 +8662,7 @@ render = function(list) {{
|
||||
${{wolButton}}
|
||||
${{notesButton}}
|
||||
${{logsButton}}
|
||||
${{permissions.manage ? `<a class="btn" href="/router/${{encodeURIComponent(r.id)}}/xray-control" target="_blank" rel="noopener noreferrer">Remote управление Xray</a>` : ''}}
|
||||
${{permissions.config ? `<a class="btn" href="${{escapeAttr(r.config_url)}}">OpenWrt config</a>` : '<span class="btn disabled">OpenWrt config</span>'}}
|
||||
${{permissions.delete ? `<button class="btn" data-delete="${{escapeAttr(r.id)}}">Удалить</button>` : '<span class="btn disabled">Удалить</span>'}}
|
||||
</div>
|
||||
@@ -12886,6 +13015,108 @@ label{display:block;margin:14px 0 6px;font-weight:700}textarea,input{display:blo
|
||||
</script></body></html>'''.replace('__COMMAND__', html.escape(default_command)).replace('__CSRF__', json.dumps(csrf))
|
||||
|
||||
|
||||
def router_xray_control_html(router, csrf):
|
||||
title = html.escape(str(router.get('name') or router['id']))
|
||||
endpoint = json.dumps('/api/router/' + urllib.parse.quote(router['id'], safe='') + '/xray-control')
|
||||
return r'''<!doctype html><html lang="ru"><head><meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1"><title>Remote управление Xray — __TITLE__</title>
|
||||
<style>
|
||||
:root{color-scheme:dark;--bg:#07040f;--panel:#191226;--panel2:#30243e;--text:#f5f3ff;--muted:#c4b5d9;--line:#574267}
|
||||
*{box-sizing:border-box}body{margin:0;min-height:100vh;background:radial-gradient(ellipse at top,#3d205b,transparent 70%),var(--bg);color:var(--text);font:14px/1.5 system-ui,sans-serif}
|
||||
.wrap{max-width:960px;margin:auto;padding:24px}.panel{padding:20px;border:1px solid var(--line);border-radius:14px;background:var(--panel)}
|
||||
.head,.actions{display:flex;flex-wrap:wrap;gap:10px;align-items:center}.head{justify-content:space-between}h1{font-size:22px;margin:0}h2{font-size:17px;margin:12px 0;overflow-wrap:anywhere}
|
||||
.btn{display:inline-flex;align-items:center;justify-content:center;min-height:42px;padding:10px 15px;border:1px solid var(--line);border-radius:9px;background:var(--panel2);color:var(--text);font:700 13px system-ui;cursor:pointer;text-decoration:none}
|
||||
.start{background:#166534}.stop{background:#991b1b}.restart{background:#854d0e}.btn:disabled{opacity:.5;cursor:default}
|
||||
.info{margin:16px 0;padding:12px;border:1px solid var(--line);border-radius:10px;overflow-wrap:anywhere}.muted{color:var(--muted)}
|
||||
.ok{color:#86efac}.warn{color:#fde68a}.error{color:#fca5a5}#result{overflow-wrap:anywhere}
|
||||
#resultOutput{margin:8px 0 0;white-space:pre-wrap;font:inherit}.operationTimer{margin-top:12px;padding-top:10px;border-top:1px solid var(--line);color:var(--muted);font-variant-numeric:tabular-nums;white-space:pre-line}.clockLine{font-variant-numeric:tabular-nums}.journalHead{display:flex;justify-content:space-between;align-items:center;flex-wrap:wrap;gap:10px;margin-top:20px}.journalHead h2{margin:0}.clear{border-color:#ef444470}
|
||||
.history{display:grid;gap:10px;margin-top:14px}.entry{border:1px solid var(--line);border-radius:10px;padding:12px;overflow-wrap:anywhere}.entry p{margin:6px 0 0;white-space:pre-wrap}.entry small{color:var(--muted)}
|
||||
@media(max-width:600px){.wrap{padding:12px}.panel{padding:14px}.actions{display:grid;grid-template-columns:1fr}.head .btn,.journalHead .btn{width:100%}h1{font-size:20px}}
|
||||
</style></head><body><main class="wrap"><section class="panel">
|
||||
<div class="head"><h1>Remote управление Xray</h1><a href="/" class="btn">Вернуться в Hub</a></div><h2 id="routerName">__TITLE__</h2>
|
||||
<p class="muted">Управление Xray выбранного роутера через агент Hub. Команда доставляется при следующем Heartbeat. Остановка Xray сохраняет связь агента с Hub.</p>
|
||||
<div class="info" role="status"><strong id="xrayStatus">Получаю статус…</strong><div id="agentStatus" class="muted"></div></div>
|
||||
<div class="actions"><button class="btn start" data-action="start">Запустить Xray</button><button class="btn stop" data-action="stop">Остановить Xray</button><button class="btn restart" data-action="restart">Перезапустить Xray</button></div>
|
||||
<div class="info" id="result"><div role="status"><strong id="resultTitle">Получаю результаты команд…</strong><pre id="resultOutput"></pre></div><div id="operationTimer" class="operationTimer" role="timer" aria-live="off" hidden></div></div>
|
||||
<div class="journalHead"><h2>Журнал действий</h2><button type="button" class="btn clear" id="clearHistory" disabled title="Очистить завершённые записи и их вывод. Текущая команда продолжит работу.">Очистить логи</button></div><div id="history" class="history"></div>
|
||||
</section></main><script>
|
||||
(()=>{
|
||||
const endpoint=__ENDPOINT__,csrf=__CSRF__,buttons=[...document.querySelectorAll('[data-action]')],result=document.getElementById('result'),history=document.getElementById('history');
|
||||
const resultTitle=document.getElementById('resultTitle'),resultOutput=document.getElementById('resultOutput'),operationTimer=document.getElementById('operationTimer'),clearHistory=document.getElementById('clearHistory');
|
||||
const labels={start:'Запустить Xray',stop:'Остановить Xray',restart:'Перезапустить Xray'}, states={queued:'Ожидает Heartbeat',delivered:'Доставлена агенту',running:'Выполняется на роутере',succeeded:'Успешно',failed:'Ошибка',interrupted:'Выполнение прервано',expired:'Не доставлена',unconfirmed:'Результат не подтверждён'};
|
||||
let timer=null,clockTimer=null,request=null,stopped=false,busy=false,snapshot=null,posting=false,serverBase=0,clockBase=0;
|
||||
const stamp=value=>value?new Date(value*1000).toLocaleString('ru-RU'):'нет данных';
|
||||
const active=state=>['queued','delivered','running'].includes(state),tone=state=>state==='succeeded'?'ok':['failed','interrupted'].includes(state)?'error':'warn';
|
||||
const duration=value=>{const seconds=Math.max(0,Math.floor(value));return String(Math.floor(seconds/60)).padStart(2,'0')+':'+String(seconds%60).padStart(2,'0');};
|
||||
const serverNow=()=>serverBase+(performance.now()-clockBase)/1000;
|
||||
function controls(){buttons.forEach(button=>button.disabled=posting||!snapshot||!snapshot.supported||snapshot.history.some(item=>active(item.status)));clearHistory.disabled=posting||!snapshot||!snapshot.history.some(item=>!active(item.status));}
|
||||
function timing(item,detail=false){
|
||||
const now=serverNow(),elapsed=Math.max(0,(item.completed_at||now)-item.created_at);
|
||||
if(!active(item.status))return 'Длительность ожидания и выполнения: '+duration(elapsed);
|
||||
let text='Прошло: '+duration(elapsed);
|
||||
if(!detail)return text;
|
||||
const deadline=item.created_at+snapshot.command_timeout_seconds,remaining=Math.max(0,deadline-now),interval=snapshot.heartbeat_interval;
|
||||
text+=' · До предела ожидания: '+duration(remaining);
|
||||
if(remaining===0)return text+'\nПредел ожидания достигнут. Ожидается итоговый статус от Hub.';
|
||||
if(!snapshot.online)return text+'\nАгент оффлайн. Ожидаем восстановления Heartbeat; время ответа пока неизвестно.';
|
||||
const delivery=item.delivered_at||Math.max(snapshot.last_seen+interval,item.created_at);
|
||||
const estimate=Math.min(deadline,delivery+snapshot.execution_timeout_seconds+interval+5);
|
||||
if(item.status==='queued')text+='\n'+(snapshot.last_seen+interval>now?'До ближайшего Heartbeat: примерно '+duration(snapshot.last_seen+interval-now)+'.':'Ожидаем ближайший Heartbeat.');
|
||||
text+='\n'+(estimate>now?'Ориентир до итогового ответа: ~'+duration(estimate-now)+'.':'Ответ задерживается. Ожидаем подтверждения агента.');
|
||||
return text;
|
||||
}
|
||||
function drawTimings(){
|
||||
if(!snapshot)return;
|
||||
const latest=snapshot.history[0];operationTimer.hidden=!latest;
|
||||
operationTimer.textContent=latest?timing(latest,true):'';
|
||||
history.querySelectorAll('[data-timing-id]').forEach(node=>{const item=snapshot.history.find(item=>item.id===node.dataset.timingId);if(item)node.textContent=timing(item);});
|
||||
}
|
||||
function scheduleClock(){
|
||||
if(clockTimer!==null)clearTimeout(clockTimer);clockTimer=null;drawTimings();
|
||||
if(!stopped&&!document.hidden&&snapshot&&snapshot.history.some(item=>active(item.status)))clockTimer=setTimeout(scheduleClock,1000);
|
||||
}
|
||||
function showError(message){result.className='info error';resultTitle.textContent=message;resultOutput.textContent='';}
|
||||
function render(data){
|
||||
snapshot=data;serverBase=data.server_time;clockBase=performance.now();document.getElementById('routerName').textContent=data.name;
|
||||
const status=document.getElementById('xrayStatus');status.className=data.online?(data.xray==='running'?'ok':'warn'):'warn';
|
||||
status.textContent=(data.online?'Xray: ':'Последний известный статус Xray: ')+({running:'запущен',stopped:'остановлен'}[data.xray]||'неизвестен');
|
||||
document.getElementById('agentStatus').textContent=(data.online?'Агент онлайн':'Агент оффлайн')+' · Подтверждено: '+stamp(data.last_seen)+(data.supported?'':' · Обнови агент роутера для управления через Heartbeat.');
|
||||
const latest=data.history[0];result.className='info '+(latest?tone(latest.status):'muted');
|
||||
resultTitle.textContent=latest?(states[latest.status]||latest.status)+' — '+labels[latest.action]:data.supported?'Журнал действий пуст.':'На роутере установлен агент без поддержки этой функции. Сначала обнови его.';
|
||||
resultOutput.textContent=latest?(latest.result||'Ожидается ответ агента.'):'';
|
||||
history.replaceChildren();
|
||||
data.history.forEach(item=>{const entry=document.createElement('article');entry.className='entry';const title=document.createElement('strong');title.className=tone(item.status);title.textContent=labels[item.action]+' · '+(states[item.status]||item.status);const time=document.createElement('small');time.textContent=stamp(item.created_at);const clock=document.createElement('p');clock.className='muted clockLine';clock.dataset.timingId=item.id;const p=document.createElement('p');p.textContent=item.result||'Ожидание доставки и результата';entry.append(title,document.createElement('br'),time,clock,p);history.append(entry);});controls();scheduleClock();
|
||||
}
|
||||
async function api(payload){
|
||||
request=new AbortController();const timeout=setTimeout(()=>request.abort(),10000);
|
||||
try{const response=await fetch(endpoint,{cache:'no-store',signal:request.signal,...(payload?{method:'POST',headers:{'Content-Type':'application/json','X-Xray-Control-CSRF':csrf},body:JSON.stringify(payload)}:{})});const data=await response.json();if(!response.ok)throw new Error(data.error||'HTTP '+response.status);render(data);}
|
||||
finally{clearTimeout(timeout);request=null;}
|
||||
}
|
||||
function schedule(){if(timer!==null)clearTimeout(timer);timer=null;if(!stopped&&!document.hidden)timer=setTimeout(refresh,3000);}
|
||||
async function refresh(){if(busy||stopped||document.hidden)return;busy=true;try{await api();}catch(error){if(error.name!=='AbortError')showError('Не удалось получить состояние: '+error.message);}finally{busy=false;schedule();}}
|
||||
buttons.forEach(button=>button.addEventListener('click',async()=>{
|
||||
if(busy||posting)return;
|
||||
const bytes=crypto.getRandomValues(new Uint8Array(16)),id=[...bytes].map(b=>b.toString(16).padStart(2,'0')).join('');
|
||||
busy=true;posting=true;controls();if(timer!==null)clearTimeout(timer);
|
||||
try{await api({action:button.dataset.action,request_id:id});}
|
||||
catch(error){showError('Не удалось подтвердить отправку: '+error.message+'. Проверь журнал перед повтором.');}
|
||||
finally{busy=false;posting=false;controls();schedule();}
|
||||
}));
|
||||
clearHistory.addEventListener('click',async()=>{
|
||||
if(busy||posting||clearHistory.disabled)return;
|
||||
busy=true;posting=true;controls();if(timer!==null)clearTimeout(timer);
|
||||
try{await api({action:'clear_history'});}
|
||||
catch(error){showError('Не удалось очистить журнал действий: '+error.message);}
|
||||
finally{busy=false;posting=false;controls();schedule();}
|
||||
});
|
||||
function pauseTimers(){if(timer!==null)clearTimeout(timer);timer=null;if(clockTimer!==null)clearTimeout(clockTimer);clockTimer=null;}
|
||||
document.addEventListener('visibilitychange',()=>{if(document.hidden)pauseTimers();else{scheduleClock();refresh();}});
|
||||
window.addEventListener('pagehide',()=>{stopped=true;pauseTimers();if(request)request.abort();});
|
||||
window.addEventListener('pageshow',()=>{stopped=false;scheduleClock();refresh();});refresh();
|
||||
})();
|
||||
</script></body></html>'''.replace('__TITLE__', title).replace('__ENDPOINT__', endpoint).replace('__CSRF__', json.dumps(csrf))
|
||||
|
||||
|
||||
def router_logs_html(router):
|
||||
title = html.escape(str(router.get('name') or router['id']))
|
||||
endpoint = json.dumps('/api/router/' + urllib.parse.quote(router['id'], safe='') + '/logs')
|
||||
@@ -13521,7 +13752,7 @@ button:hover{{filter:brightness(1.06)}}
|
||||
<form class="login" method="post" action="/login">
|
||||
{error_html}
|
||||
<span class="brand">
|
||||
<h1 class="appBanner"><span>OpenWrt Remote Hub <span class="appBannerVersion">v120</span></span></h1>
|
||||
<h1 class="appBanner"><span>OpenWrt Remote Hub <span class="appBannerVersion">v121</span></span></h1>
|
||||
</span>
|
||||
<label for="hubUsername">Логин</label>
|
||||
<input id="hubUsername" name="username" autocomplete="off" autofocus required>
|
||||
@@ -13993,7 +14224,7 @@ body::after{{content:"";position:fixed;inset:0;pointer-events:none;background:li
|
||||
<circle cx="65" cy="59" r="3" fill="#E5F2FF"/>
|
||||
</svg>
|
||||
</div>
|
||||
<h2 class="brandTitle">OpenWrt Remote Hub <span class="brandVersion">v120</span></h2>
|
||||
<h2 class="brandTitle">OpenWrt Remote Hub <span class="brandVersion">v121</span></h2>
|
||||
</div>
|
||||
</div>
|
||||
<div class="brandBottom">
|
||||
@@ -16002,6 +16233,7 @@ class App:
|
||||
self.agent_token = agent
|
||||
self.public_url = public_url.rstrip("/")
|
||||
self.router_state_lock = threading.Lock()
|
||||
self.xray_control_csrf = secrets.token_urlsafe(32)
|
||||
self.router_state_snapshot = {}
|
||||
self.router_monitor_stop = threading.Event()
|
||||
self.router_monitor_thread = None
|
||||
@@ -17546,6 +17778,45 @@ a{{display:inline-flex;margin-top:18px;color:#93c5fd}}
|
||||
self.send_bytes(200, router_logs_html(row_to_router(row)).encode('utf-8'), 'text/html; charset=utf-8',
|
||||
[('Cache-Control', 'no-store')])
|
||||
|
||||
def router_xray_control_page(self, router_id):
|
||||
if not self.require_router_access(router_id, 'G'):
|
||||
return
|
||||
with self.app.conn() as conn:
|
||||
row = get_active_router(conn, router_id)
|
||||
if not row:
|
||||
self.send_text(404, 'router not found')
|
||||
return
|
||||
self.send_bytes(200, router_xray_control_html(row_to_router(row), self.app.xray_control_csrf).encode(), 'text/html; charset=utf-8')
|
||||
|
||||
def router_xray_control_api(self, router_id):
|
||||
if not self.require_router_access(router_id, 'G', json_mode=True):
|
||||
return
|
||||
try:
|
||||
payload = None
|
||||
if self.command == 'POST':
|
||||
if (not secrets.compare_digest(self.headers.get('X-Xray-Control-CSRF', ''), self.app.xray_control_csrf)
|
||||
or self.headers.get('Origin') and self.headers['Origin'] != self.request_origin()):
|
||||
self.send_json(403, {'ok': False, 'error': 'Обнови вкладку управления и повтори команду.'})
|
||||
return
|
||||
length = self.headers.get('Content-Length', '')
|
||||
if (self.headers.get('Transfer-Encoding') or not length.isdigit() or not 0 < int(length) <= 1024
|
||||
or 'application/json' not in self.headers.get('Content-Type', '')):
|
||||
self.send_json(400, {'ok': False, 'error': 'Ожидается небольшой запрос JSON.'})
|
||||
return
|
||||
payload = self.read_payload()
|
||||
if not isinstance(payload, dict):
|
||||
raise ValueError('Ожидается объект JSON.')
|
||||
with self.app.conn() as conn:
|
||||
if payload is not None:
|
||||
if payload.get('action') == 'clear_history':
|
||||
xray_control_clear_history(conn, router_id)
|
||||
else:
|
||||
xray_control_enqueue(conn, router_id, payload.get('action'), payload.get('request_id'))
|
||||
snapshot = xray_control_snapshot(conn, router_id)
|
||||
self.send_json(200, snapshot)
|
||||
except ValueError as exc:
|
||||
self.send_json(400, {'ok': False, 'error': str(exc)})
|
||||
|
||||
def router_logs_api(self, router_id, mode='live'):
|
||||
if not self.require_router_access(router_id, 'G', json_mode=True):
|
||||
return
|
||||
@@ -19377,6 +19648,10 @@ exit 127
|
||||
return
|
||||
self.send_json(200, push_status_snapshot())
|
||||
return
|
||||
control_match = re.fullmatch(r'/api/router/([^/]+)/xray-control', path)
|
||||
if control_match:
|
||||
self.router_xray_control_api(urllib.parse.unquote(control_match[1]))
|
||||
return
|
||||
log_match = re.fullmatch(r'/api/router/([^/]+)/logs(?:/(download))?', path)
|
||||
if log_match:
|
||||
self.router_logs_api(urllib.parse.unquote(log_match[1]), log_match[2] or 'live')
|
||||
@@ -19401,6 +19676,9 @@ exit 127
|
||||
self.send_json(400, {"ok": False, "error": str(exc), "router_id": router_id, "devices": []})
|
||||
return
|
||||
if path.startswith("/router/"):
|
||||
if path.endswith('/xray-control'):
|
||||
self.router_xray_control_page(self.router_id_from_path('/router/'))
|
||||
return
|
||||
if path.endswith('/logs'):
|
||||
self.router_logs_page(self.router_id_from_path('/router/'))
|
||||
return
|
||||
@@ -19419,6 +19697,10 @@ exit 127
|
||||
|
||||
def do_POST(self):
|
||||
path = self.parsed().path
|
||||
control_match = re.fullmatch(r'/api/router/([^/]+)/xray-control', path)
|
||||
if control_match:
|
||||
self.router_xray_control_api(urllib.parse.unquote(control_match[1]))
|
||||
return
|
||||
if path in {'/api/hub-update/check', '/api/hub-update/start'}:
|
||||
self.hub_update_api(path.rsplit('/', 1)[-1])
|
||||
return
|
||||
@@ -19457,6 +19739,7 @@ exit 127
|
||||
payload = self.read_payload()
|
||||
with self.app.conn() as conn:
|
||||
router = heartbeat(conn, payload)
|
||||
xray_command = xray_control_exchange(conn, router['id'], payload)
|
||||
if router and router.get('_became_online'):
|
||||
record_router_connection_log(conn, router['id'], True)
|
||||
if router and router.pop("_became_online", False):
|
||||
@@ -19481,6 +19764,7 @@ exit 127
|
||||
"ok": True,
|
||||
"router": router,
|
||||
"hub_update": canonical_router_hub_update(router, self.app.public_url, self.request_origin()),
|
||||
"xray_command": xray_command,
|
||||
"xray_reload": xray_reload,
|
||||
"xray_restart": xray_restart,
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user