Add Console action to configure tunnels without re-registering
This commit is contained in:
parent
97f2594906
commit
ffca356006
|
|
@ -413,6 +413,17 @@ RUN THIS ON VPS
|
||||||
|
|
||||||
### Что делать после настройки VPS
|
### Что делать после настройки VPS
|
||||||
|
|
||||||
|
Если устройство уже зарегистрировано, но автоматическая настройка туннелей
|
||||||
|
при регистрации была пропущена или завершилась ошибкой, откройте Edge Console →
|
||||||
|
«Состояние» → Reverse Tunnels → «Настроить». Console использует сохранённые
|
||||||
|
данные регистрации клиента, повторно настраивает доступ на сервере и
|
||||||
|
перезапускает службы туннелей. Перерегистрация не нужна.
|
||||||
|
|
||||||
|
Каждый клик запускает одну попытку; фоновых повторов нет. Пока настройка идёт,
|
||||||
|
повторный запуск заблокирован. При ошибке устраните её причину и нажмите кнопку
|
||||||
|
ещё раз. Стадия `stage_reverse_tunnels` должна быть установлена: кнопка не
|
||||||
|
устанавливает пакеты и не создаёт отсутствующие SSH-ключи или systemd-службы.
|
||||||
|
|
||||||
После того как серверная команда выполнена, перезагрузи Edge:
|
После того как серверная команда выполнена, перезагрузи Edge:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|
|
||||||
|
|
@ -313,6 +313,7 @@ print_summary() {
|
||||||
if [[ -z "$TUNNEL_HOST" ]]; then
|
if [[ -z "$TUNNEL_HOST" ]]; then
|
||||||
echo "Status: waiting for cloud registration (services will skip startup until configured)."
|
echo "Status: waiting for cloud registration (services will skip startup until configured)."
|
||||||
echo "Register the device in Edge Console to enroll and start the tunnels automatically."
|
echo "Register the device in Edge Console to enroll and start the tunnels automatically."
|
||||||
|
echo "If already registered, use Health > Reverse Tunnels > Configure in Edge Console."
|
||||||
echo "============================================================"
|
echo "============================================================"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
@ -336,7 +337,7 @@ print_summary() {
|
||||||
echo "$vps_bootstrap_cmd"
|
echo "$vps_bootstrap_cmd"
|
||||||
echo
|
echo
|
||||||
echo "IMPORTANT:"
|
echo "IMPORTANT:"
|
||||||
echo "Register/reconnect the device in Edge Console to enroll and start tunnels automatically."
|
echo "Use Health > Reverse Tunnels > Configure in Edge Console to enroll and start tunnels without re-registering."
|
||||||
echo "For manual enrollment, run the VPS command above, then restart the tunnel services or reboot EDGE."
|
echo "For manual enrollment, run the VPS command above, then restart the tunnel services or reboot EDGE."
|
||||||
echo "============================================================"
|
echo "============================================================"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ from http.cookies import SimpleCookie
|
||||||
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
|
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
|
||||||
from urllib.parse import parse_qs, urlparse
|
from urllib.parse import parse_qs, urlparse
|
||||||
from zoneinfo import ZoneInfo, ZoneInfoNotFoundError
|
from zoneinfo import ZoneInfo, ZoneInfoNotFoundError
|
||||||
from itscreen_registration import get_registration_status, register_device, reset_registration
|
from itscreen_registration import configure_reverse_tunnel, get_registration_status, register_device, reset_registration
|
||||||
from modbus_backend import (
|
from modbus_backend import (
|
||||||
ApiError as ModbusApiError,
|
ApiError as ModbusApiError,
|
||||||
acquire_session as modbus_acquire_session,
|
acquire_session as modbus_acquire_session,
|
||||||
|
|
@ -3807,6 +3807,18 @@ class Handler(BaseHTTPRequestHandler):
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
self.send_json({"ok": False, "error": str(exc)}, code=500)
|
self.send_json({"ok": False, "error": str(exc)}, code=500)
|
||||||
return
|
return
|
||||||
|
if parsed.path == "/api/itscreen/reverse-tunnel/configure":
|
||||||
|
try:
|
||||||
|
response = configure_reverse_tunnel()
|
||||||
|
invalidate_cache()
|
||||||
|
self.send_json(response)
|
||||||
|
except ValueError as exc:
|
||||||
|
self.send_json({"ok": False, "error": str(exc)}, code=400)
|
||||||
|
except RuntimeError as exc:
|
||||||
|
self.send_json({"ok": False, "error": str(exc)}, code=409)
|
||||||
|
except Exception:
|
||||||
|
self.send_json({"ok": False, "error": "Reverse tunnel setup failed. Check the tunnel services and try again."}, code=502)
|
||||||
|
return
|
||||||
if parsed.path == "/api/itscreen/registration/register":
|
if parsed.path == "/api/itscreen/registration/register":
|
||||||
payload = self.read_json_body()
|
payload = self.read_json_body()
|
||||||
if payload is None:
|
if payload is None:
|
||||||
|
|
|
||||||
|
|
@ -480,6 +480,27 @@ def _enroll_reverse_tunnel(state):
|
||||||
return tunnel
|
return tunnel
|
||||||
|
|
||||||
|
|
||||||
|
def configure_reverse_tunnel():
|
||||||
|
"""Retry enrollment once from the client's current registration, without registering again."""
|
||||||
|
if not _REGISTRATION_LOCK.acquire(blocking=False):
|
||||||
|
raise RuntimeError("Registration or tunnel setup is already in progress")
|
||||||
|
try:
|
||||||
|
identity = _device_identity()
|
||||||
|
state = _load_registration_from_itscreen_config(identity["device_id"])
|
||||||
|
if not state or not state.get("local_registered"):
|
||||||
|
raise ValueError("Device registration is unavailable. Register the device first.")
|
||||||
|
# A temporary cloud disconnect must not require re-registration. The
|
||||||
|
# enrollment endpoint verifies the saved credentials on this attempt.
|
||||||
|
tunnel = _enroll_reverse_tunnel(state)
|
||||||
|
return {
|
||||||
|
"ok": True,
|
||||||
|
"message": "Reverse tunnel configuration applied; services restarted.",
|
||||||
|
"reverse_tunnel": tunnel,
|
||||||
|
}
|
||||||
|
finally:
|
||||||
|
_REGISTRATION_LOCK.release()
|
||||||
|
|
||||||
|
|
||||||
def _registration_transport_interrupted(exc):
|
def _registration_transport_interrupted(exc):
|
||||||
text = str(exc or "").lower()
|
text = str(exc or "").lower()
|
||||||
return isinstance(exc, TimeoutError) or any(marker in text for marker in (
|
return isinstance(exc, TimeoutError) or any(marker in text for marker in (
|
||||||
|
|
@ -1316,6 +1337,15 @@ def _register_device_once(host, token=""):
|
||||||
|
|
||||||
|
|
||||||
def reset_registration():
|
def reset_registration():
|
||||||
|
if not _REGISTRATION_LOCK.acquire(blocking=False):
|
||||||
|
raise RuntimeError("Registration or tunnel setup is already in progress")
|
||||||
|
try:
|
||||||
|
return _reset_registration_once()
|
||||||
|
finally:
|
||||||
|
_REGISTRATION_LOCK.release()
|
||||||
|
|
||||||
|
|
||||||
|
def _reset_registration_once():
|
||||||
persisted = load_state()
|
persisted = load_state()
|
||||||
if _registration_is_absent(persisted):
|
if _registration_is_absent(persisted):
|
||||||
cleared = _cleared_registration_state(persisted)
|
cleared = _cleared_registration_state(persisted)
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,27 @@
|
||||||
import pathlib
|
import pathlib
|
||||||
|
import json
|
||||||
|
import tempfile
|
||||||
|
import threading
|
||||||
import unittest
|
import unittest
|
||||||
|
from unittest.mock import Mock, patch
|
||||||
|
|
||||||
|
import app
|
||||||
|
import itscreen_registration as registration
|
||||||
|
|
||||||
|
|
||||||
ROOT = pathlib.Path(__file__).resolve().parents[1]
|
ROOT = pathlib.Path(__file__).resolve().parents[1]
|
||||||
|
|
||||||
|
|
||||||
class ReverseTunnelActionsContractTest(unittest.TestCase):
|
class ReverseTunnelActionsContractTest(unittest.TestCase):
|
||||||
|
def test_configuration_is_an_explicit_action_in_the_existing_card(self):
|
||||||
|
frontend = (ROOT / "frontend" / "console.js").read_text(encoding="utf-8")
|
||||||
|
card = frontend.split("function renderReverseTunnelCard(card) {", 1)[1].split("function normalizeItscreenHostCandidate", 1)[0]
|
||||||
|
self.assertIn('onclick="window.__configureReverseTunnel()"', card)
|
||||||
|
self.assertIn('restartBusy || configuring ? "disabled"', card)
|
||||||
|
index = (ROOT / "frontend" / "index.html").read_text()
|
||||||
|
self.assertIn('console.js?v=2.2.81', index)
|
||||||
|
self.assertIn('console.i18n.js?v=2.2.81', index)
|
||||||
|
|
||||||
def test_card_restarts_all_units_and_exposes_local_service_links(self):
|
def test_card_restarts_all_units_and_exposes_local_service_links(self):
|
||||||
backend = (ROOT / "backend" / "app.py").read_text(encoding="utf-8")
|
backend = (ROOT / "backend" / "app.py").read_text(encoding="utf-8")
|
||||||
frontend = (ROOT / "frontend" / "console.js").read_text(encoding="utf-8")
|
frontend = (ROOT / "frontend" / "console.js").read_text(encoding="utf-8")
|
||||||
|
|
@ -26,5 +42,117 @@ class ReverseTunnelActionsContractTest(unittest.TestCase):
|
||||||
self.assertIn('console.css?v=2.2.80', index)
|
self.assertIn('console.css?v=2.2.80', index)
|
||||||
|
|
||||||
|
|
||||||
|
class ReverseTunnelConfigurationTest(unittest.TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
self.directory = tempfile.TemporaryDirectory()
|
||||||
|
self.addCleanup(self.directory.cleanup)
|
||||||
|
self.store = pathlib.Path(self.directory.name) / "registration.ini"
|
||||||
|
self.config = pathlib.Path(self.directory.name) / "it-screen.conf"
|
||||||
|
self.lock = threading.Lock()
|
||||||
|
for name, value in (
|
||||||
|
("REGISTRATION_STORE_PATH", str(self.store)),
|
||||||
|
("ITSCREEN_CONFIG_PATH", str(self.config)),
|
||||||
|
("_REGISTRATION_LOCK", self.lock),
|
||||||
|
):
|
||||||
|
patcher = patch.object(registration, name, value)
|
||||||
|
patcher.start()
|
||||||
|
self.addCleanup(patcher.stop)
|
||||||
|
self.store.write_text("[General]\nserver=rest.example.com\ndevice_name=g-box-deadbeef\npassword=device-secret\nis_registered=true\nis_logged=false\n")
|
||||||
|
|
||||||
|
def test_retry_reads_current_credentials_without_registration_or_persistence(self):
|
||||||
|
with patch.object(registration, "_enroll_reverse_tunnel", return_value={"ssh_host": "gateway.example.com"}) as enroll, \
|
||||||
|
patch.object(registration, "register_device") as register, \
|
||||||
|
patch.object(registration, "save_state") as save:
|
||||||
|
result = registration.configure_reverse_tunnel()
|
||||||
|
enroll.assert_called_once()
|
||||||
|
state = enroll.call_args.args[0]
|
||||||
|
self.assertEqual("device-secret", state["password"])
|
||||||
|
self.assertEqual("rest.example.com", state["host"])
|
||||||
|
self.assertFalse(state["logged"])
|
||||||
|
self.assertTrue(result["ok"])
|
||||||
|
self.assertNotIn("device-secret", json.dumps(result))
|
||||||
|
register.assert_not_called()
|
||||||
|
save.assert_not_called()
|
||||||
|
self.assertFalse(self.lock.locked())
|
||||||
|
|
||||||
|
def test_missing_or_cleared_registration_does_not_enroll(self):
|
||||||
|
for text in ("", "server=rest.example.com\nis_registered=false\npassword=old-secret\n"):
|
||||||
|
self.store.write_text(text)
|
||||||
|
with patch.object(registration, "_enroll_reverse_tunnel") as enroll:
|
||||||
|
with self.assertRaisesRegex(ValueError, "registration is unavailable"):
|
||||||
|
registration.configure_reverse_tunnel()
|
||||||
|
enroll.assert_not_called()
|
||||||
|
self.assertFalse(self.lock.locked())
|
||||||
|
|
||||||
|
def test_failure_is_not_retried_automatically_and_next_click_uses_new_data(self):
|
||||||
|
with patch.object(registration, "_enroll_reverse_tunnel", side_effect=RuntimeError("offline")) as enroll:
|
||||||
|
with self.assertRaisesRegex(RuntimeError, "offline"):
|
||||||
|
registration.configure_reverse_tunnel()
|
||||||
|
enroll.assert_called_once()
|
||||||
|
self.assertFalse(self.lock.locked())
|
||||||
|
self.store.write_text(self.store.read_text().replace("device-secret", "updated-secret"))
|
||||||
|
with patch.object(registration, "_enroll_reverse_tunnel", return_value={}) as retry:
|
||||||
|
self.assertTrue(registration.configure_reverse_tunnel()["ok"])
|
||||||
|
self.assertEqual("updated-secret", retry.call_args.args[0]["password"])
|
||||||
|
|
||||||
|
def test_parallel_setup_and_registration_reset_are_rejected(self):
|
||||||
|
self.lock.acquire()
|
||||||
|
try:
|
||||||
|
with patch.object(registration, "_enroll_reverse_tunnel") as enroll, \
|
||||||
|
patch.object(registration, "_reset_registration_once") as reset:
|
||||||
|
for action in (registration.configure_reverse_tunnel, registration.reset_registration):
|
||||||
|
with self.assertRaisesRegex(RuntimeError, "already in progress"):
|
||||||
|
action()
|
||||||
|
enroll.assert_not_called()
|
||||||
|
reset.assert_not_called()
|
||||||
|
finally:
|
||||||
|
self.lock.release()
|
||||||
|
|
||||||
|
def test_enrollment_writes_gateway_and_restarts_existing_units_once(self):
|
||||||
|
config_path = pathlib.Path(self.directory.name) / "reverse-tunnel.env"
|
||||||
|
response = Mock()
|
||||||
|
response.read.return_value = json.dumps({"reverse_tunnel": {
|
||||||
|
"ssh_host": "gateway.example.com", "ssh_port": 2222,
|
||||||
|
"ssh_user": "iomatex-tunnel", "ports": {"webui": 23000},
|
||||||
|
}}).encode()
|
||||||
|
context = Mock()
|
||||||
|
context.__enter__ = Mock(return_value=response)
|
||||||
|
context.__exit__ = Mock(return_value=False)
|
||||||
|
with patch.object(registration, "REVERSE_TUNNEL_CONFIG_PATH", str(config_path)), \
|
||||||
|
patch.object(registration, "_reverse_tunnel_public_key", return_value="ssh-ed25519 test-key"), \
|
||||||
|
patch.object(registration, "urlopen", return_value=context) as request, \
|
||||||
|
patch.object(registration.subprocess, "run") as command:
|
||||||
|
result = registration.configure_reverse_tunnel()
|
||||||
|
self.assertTrue(result["ok"])
|
||||||
|
request.assert_called_once()
|
||||||
|
self.assertEqual(8, request.call_args.kwargs["timeout"])
|
||||||
|
self.assertEqual("http://rest.example.com/v2/device/reverse-tunnel", request.call_args.args[0].full_url)
|
||||||
|
self.assertIn("TUNNEL_HOST=gateway.example.com\nTUNNEL_PORT=2222\n", config_path.read_text())
|
||||||
|
command.assert_called_once_with([
|
||||||
|
"systemctl", "restart", "iomatex-rt-cockpit.service",
|
||||||
|
"iomatex-rt-z2m.service", "iomatex-rt-webui.service",
|
||||||
|
], check=True, timeout=20)
|
||||||
|
|
||||||
|
def test_endpoint_requires_console_authentication(self):
|
||||||
|
handler = object.__new__(app.Handler)
|
||||||
|
handler.path = "/api/itscreen/reverse-tunnel/configure"
|
||||||
|
handler.require_auth = Mock(return_value=False)
|
||||||
|
with patch.object(app, "configure_reverse_tunnel") as configure:
|
||||||
|
handler.do_POST()
|
||||||
|
configure.assert_not_called()
|
||||||
|
|
||||||
|
def test_authenticated_endpoint_calls_shared_owner_and_invalidates_cache(self):
|
||||||
|
handler = object.__new__(app.Handler)
|
||||||
|
handler.path = "/api/itscreen/reverse-tunnel/configure"
|
||||||
|
handler.require_auth = Mock(return_value=True)
|
||||||
|
handler.send_json = Mock()
|
||||||
|
with patch.object(app, "configure_reverse_tunnel", return_value={"ok": True}) as configure, \
|
||||||
|
patch.object(app, "invalidate_cache") as invalidate:
|
||||||
|
handler.do_POST()
|
||||||
|
configure.assert_called_once_with()
|
||||||
|
invalidate.assert_called_once_with()
|
||||||
|
handler.send_json.assert_called_once_with({"ok": True})
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,75 @@
|
||||||
|
// Run with: node test_reverse_tunnel_ui.js
|
||||||
|
const assert = require("node:assert/strict");
|
||||||
|
const fs = require("node:fs");
|
||||||
|
const path = require("node:path");
|
||||||
|
const vm = require("node:vm");
|
||||||
|
|
||||||
|
const source = fs.readFileSync(path.join(__dirname, "../frontend/console.js"), "utf8");
|
||||||
|
const handler = source.slice(
|
||||||
|
source.indexOf(" window.__configureReverseTunnel ="),
|
||||||
|
source.indexOf(" window.__toggleTunnelGroup =")
|
||||||
|
);
|
||||||
|
const card = source.slice(
|
||||||
|
source.indexOf(" function renderReverseTunnelCard(card) {"),
|
||||||
|
source.indexOf(" function normalizeItscreenHostCandidate")
|
||||||
|
);
|
||||||
|
const state = {
|
||||||
|
activeTab: "health",
|
||||||
|
reverseTunnelUi: { configuring: false, openGroups: {}, bootstrapOpen: false },
|
||||||
|
serviceActions: { busyById: {} }
|
||||||
|
};
|
||||||
|
let requests = 0;
|
||||||
|
let refreshes = 0;
|
||||||
|
let resolveRequest;
|
||||||
|
const toasts = [];
|
||||||
|
const context = {
|
||||||
|
window: {}, state,
|
||||||
|
fetchJson: async (url, options) => {
|
||||||
|
requests++;
|
||||||
|
assert.equal(url, "/api/itscreen/reverse-tunnel/configure");
|
||||||
|
assert.equal(options.method, "POST");
|
||||||
|
return new Promise(resolve => { resolveRequest = resolve; });
|
||||||
|
},
|
||||||
|
loadHealth: async () => { refreshes++; },
|
||||||
|
renderActiveTab: () => {},
|
||||||
|
showToast: (...args) => toasts.push(args),
|
||||||
|
translateUiText: value => value,
|
||||||
|
translateStatusValue: value => value,
|
||||||
|
statusTone: () => "warning",
|
||||||
|
textValue: (value, fallback) => value || fallback,
|
||||||
|
currentAccessHost: () => "edge.local",
|
||||||
|
renderPanelTitle: value => value,
|
||||||
|
renderTunnelAccordion: () => "",
|
||||||
|
esc: String,
|
||||||
|
t: value => value
|
||||||
|
};
|
||||||
|
vm.createContext(context);
|
||||||
|
vm.runInContext(card + handler, context);
|
||||||
|
|
||||||
|
(async () => {
|
||||||
|
const configure = context.window.__configureReverseTunnel;
|
||||||
|
const first = configure();
|
||||||
|
assert.equal(state.reverseTunnelUi.configuring, true);
|
||||||
|
const markup = context.renderReverseTunnelCard({ id: "reverse_tunnel", title: "Reverse Tunnels" });
|
||||||
|
assert.match(markup, /disabled onclick="window.__configureReverseTunnel\(\)"/);
|
||||||
|
assert.match(markup, /disabled onclick="window.__restartService\('reverse_tunnel'\)"/);
|
||||||
|
await configure();
|
||||||
|
assert.equal(requests, 1, "double click must not dispatch another request");
|
||||||
|
resolveRequest({ ok: true, message: "Configured" });
|
||||||
|
await first;
|
||||||
|
assert.equal(state.reverseTunnelUi.configuring, false);
|
||||||
|
assert.equal(refreshes, 1);
|
||||||
|
|
||||||
|
context.fetchJson = async () => { requests++; throw new Error("offline"); };
|
||||||
|
await configure();
|
||||||
|
assert.equal(requests, 2, "failure must not start an automatic retry");
|
||||||
|
assert.equal(state.reverseTunnelUi.configuring, false);
|
||||||
|
assert.deepEqual(toasts.at(-1), ["error", "offline"]);
|
||||||
|
await configure();
|
||||||
|
assert.equal(requests, 3, "a later click may retry");
|
||||||
|
|
||||||
|
state.serviceActions.busyById.reverse_tunnel = true;
|
||||||
|
await configure();
|
||||||
|
assert.equal(requests, 3, "setup must wait for the existing restart action");
|
||||||
|
console.log("Reverse tunnel UI: double click, busy state, failure and explicit retry passed");
|
||||||
|
})().catch(error => { console.error(error); process.exitCode = 1; });
|
||||||
|
|
@ -1880,6 +1880,16 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.assign(window.ConsoleI18n.translations.ru, {
|
Object.assign(window.ConsoleI18n.translations.ru, {
|
||||||
|
"Configure": "Настроить",
|
||||||
|
"Configuring...": "Настройка…",
|
||||||
|
"Configure remote access using the saved device registration. If setup was skipped or failed, try again here without registering the device again. Each click makes one attempt.": "Настройте удалённый доступ по сохранённым данным регистрации. Если настройка была пропущена или завершилась ошибкой, повторите её здесь без перерегистрации устройства. Каждый клик запускает одну попытку.",
|
||||||
|
"Reverse tunnel configuration applied; services restarted.": "Настройки туннелей применены; службы перезапущены.",
|
||||||
|
"Registration or tunnel setup is already in progress": "Регистрация или настройка туннелей уже выполняется",
|
||||||
|
"Device registration is unavailable. Register the device first.": "Данные регистрации недоступны. Сначала зарегистрируйте устройство.",
|
||||||
|
"Reverse tunnel setup failed. Check the tunnel services and try again.": "Не удалось настроить туннели. Проверьте службы туннелей и повторите попытку.",
|
||||||
|
"Device registration password is unavailable": "Пароль регистрации устройства недоступен",
|
||||||
|
"Reverse tunnel SSH public key was not found": "Публичный SSH-ключ туннелей не найден",
|
||||||
|
"Reverse tunnel enrollment request failed": "Не удалось отправить запрос настройки туннелей",
|
||||||
"Security & Region": "Безопасность и регион",
|
"Security & Region": "Безопасность и регион",
|
||||||
"WEB UI account security, recovery, and regional time settings.": "Безопасность учётной записи WEB UI, восстановление доступа и региональные настройки времени.",
|
"WEB UI account security, recovery, and regional time settings.": "Безопасность учётной записи WEB UI, восстановление доступа и региональные настройки времени.",
|
||||||
"Region and time zone": "Регион и часовой пояс",
|
"Region and time zone": "Регион и часовой пояс",
|
||||||
|
|
@ -1910,6 +1920,16 @@
|
||||||
"Wear is a coarse JEDEC estimate. This eMMC does not expose exact power-on hours or write cycles.": "Износ — приблизительная оценка JEDEC. Эта eMMC не сообщает точные часы работы или число циклов записи."
|
"Wear is a coarse JEDEC estimate. This eMMC does not expose exact power-on hours or write cycles.": "Износ — приблизительная оценка JEDEC. Эта eMMC не сообщает точные часы работы или число циклов записи."
|
||||||
});
|
});
|
||||||
Object.assign(window.ConsoleI18n.translations.pl, {
|
Object.assign(window.ConsoleI18n.translations.pl, {
|
||||||
|
"Configure": "Skonfiguruj",
|
||||||
|
"Configuring...": "Konfigurowanie…",
|
||||||
|
"Configure remote access using the saved device registration. If setup was skipped or failed, try again here without registering the device again. Each click makes one attempt.": "Skonfiguruj dostęp zdalny przy użyciu zapisanej rejestracji urządzenia. Jeśli konfiguracja została pominięta lub nie powiodła się, ponów ją tutaj bez ponownej rejestracji. Każde kliknięcie uruchamia jedną próbę.",
|
||||||
|
"Reverse tunnel configuration applied; services restarted.": "Konfiguracja tuneli zastosowana; usługi uruchomione ponownie.",
|
||||||
|
"Registration or tunnel setup is already in progress": "Rejestracja lub konfiguracja tuneli jest już w toku",
|
||||||
|
"Device registration is unavailable. Register the device first.": "Dane rejestracji są niedostępne. Najpierw zarejestruj urządzenie.",
|
||||||
|
"Reverse tunnel setup failed. Check the tunnel services and try again.": "Konfiguracja tuneli nie powiodła się. Sprawdź usługi tuneli i spróbuj ponownie.",
|
||||||
|
"Device registration password is unavailable": "Hasło rejestracji urządzenia jest niedostępne",
|
||||||
|
"Reverse tunnel SSH public key was not found": "Nie znaleziono publicznego klucza SSH tuneli",
|
||||||
|
"Reverse tunnel enrollment request failed": "Żądanie konfiguracji tuneli nie powiodło się",
|
||||||
"Security & Region": "Bezpieczeństwo i region",
|
"Security & Region": "Bezpieczeństwo i region",
|
||||||
"WEB UI account security, recovery, and regional time settings.": "Bezpieczeństwo konta WEB UI, odzyskiwanie dostępu i regionalne ustawienia czasu.",
|
"WEB UI account security, recovery, and regional time settings.": "Bezpieczeństwo konta WEB UI, odzyskiwanie dostępu i regionalne ustawienia czasu.",
|
||||||
"Region and time zone": "Region i strefa czasowa",
|
"Region and time zone": "Region i strefa czasowa",
|
||||||
|
|
@ -1940,6 +1960,16 @@
|
||||||
"Wear is a coarse JEDEC estimate. This eMMC does not expose exact power-on hours or write cycles.": "Zużycie jest przybliżonym oszacowaniem JEDEC. Ta pamięć eMMC nie udostępnia dokładnych godzin pracy ani liczby cykli zapisu."
|
"Wear is a coarse JEDEC estimate. This eMMC does not expose exact power-on hours or write cycles.": "Zużycie jest przybliżonym oszacowaniem JEDEC. Ta pamięć eMMC nie udostępnia dokładnych godzin pracy ani liczby cykli zapisu."
|
||||||
});
|
});
|
||||||
Object.assign(window.ConsoleI18n.translations.ar, {
|
Object.assign(window.ConsoleI18n.translations.ar, {
|
||||||
|
"Configure": "إعداد",
|
||||||
|
"Configuring...": "جارٍ الإعداد…",
|
||||||
|
"Configure remote access using the saved device registration. If setup was skipped or failed, try again here without registering the device again. Each click makes one attempt.": "اضبط الوصول عن بُعد باستخدام بيانات تسجيل الجهاز المحفوظة. إذا تم تخطي الإعداد أو فشل، أعد المحاولة هنا دون إعادة تسجيل الجهاز. كل نقرة تبدأ محاولة واحدة.",
|
||||||
|
"Reverse tunnel configuration applied; services restarted.": "تم تطبيق إعدادات الأنفاق وإعادة تشغيل الخدمات.",
|
||||||
|
"Registration or tunnel setup is already in progress": "تسجيل الجهاز أو إعداد الأنفاق قيد التنفيذ بالفعل",
|
||||||
|
"Device registration is unavailable. Register the device first.": "بيانات التسجيل غير متاحة. سجّل الجهاز أولاً.",
|
||||||
|
"Reverse tunnel setup failed. Check the tunnel services and try again.": "فشل إعداد الأنفاق. تحقق من خدمات الأنفاق وحاول مرة أخرى.",
|
||||||
|
"Device registration password is unavailable": "كلمة مرور تسجيل الجهاز غير متاحة",
|
||||||
|
"Reverse tunnel SSH public key was not found": "لم يتم العثور على مفتاح SSH العام للأنفاق",
|
||||||
|
"Reverse tunnel enrollment request failed": "فشل طلب إعداد الأنفاق",
|
||||||
"Security & Region": "الأمان والمنطقة",
|
"Security & Region": "الأمان والمنطقة",
|
||||||
"WEB UI account security, recovery, and regional time settings.": "أمان حساب واجهة الويب واستعادة الوصول وإعدادات الوقت الإقليمية.",
|
"WEB UI account security, recovery, and regional time settings.": "أمان حساب واجهة الويب واستعادة الوصول وإعدادات الوقت الإقليمية.",
|
||||||
"Region and time zone": "المنطقة والمنطقة الزمنية",
|
"Region and time zone": "المنطقة والمنطقة الزمنية",
|
||||||
|
|
@ -1970,6 +2000,16 @@
|
||||||
"Wear is a coarse JEDEC estimate. This eMMC does not expose exact power-on hours or write cycles.": "التآكل تقدير JEDEC تقريبي. لا تعرض ذاكرة eMMC هذه ساعات التشغيل الدقيقة أو عدد دورات الكتابة."
|
"Wear is a coarse JEDEC estimate. This eMMC does not expose exact power-on hours or write cycles.": "التآكل تقدير JEDEC تقريبي. لا تعرض ذاكرة eMMC هذه ساعات التشغيل الدقيقة أو عدد دورات الكتابة."
|
||||||
});
|
});
|
||||||
Object.assign(window.ConsoleI18n.translations.hi, {
|
Object.assign(window.ConsoleI18n.translations.hi, {
|
||||||
|
"Configure": "कॉन्फ़िगर करें",
|
||||||
|
"Configuring...": "कॉन्फ़िगर हो रहा है…",
|
||||||
|
"Configure remote access using the saved device registration. If setup was skipped or failed, try again here without registering the device again. Each click makes one attempt.": "सहेजे गए डिवाइस पंजीकरण से रिमोट एक्सेस सेट करें। सेटअप छूट गया या विफल हुआ हो तो डिवाइस को दोबारा पंजीकृत किए बिना यहाँ पुनः प्रयास करें। हर क्लिक एक प्रयास शुरू करता है।",
|
||||||
|
"Reverse tunnel configuration applied; services restarted.": "टनल सेटिंग्स लागू हुईं; सेवाएँ पुनः शुरू हुईं।",
|
||||||
|
"Registration or tunnel setup is already in progress": "पंजीकरण या टनल सेटअप पहले से चल रहा है",
|
||||||
|
"Device registration is unavailable. Register the device first.": "पंजीकरण डेटा उपलब्ध नहीं है। पहले डिवाइस पंजीकृत करें।",
|
||||||
|
"Reverse tunnel setup failed. Check the tunnel services and try again.": "टनल सेटअप विफल हुआ। टनल सेवाएँ जाँचें और फिर प्रयास करें।",
|
||||||
|
"Device registration password is unavailable": "डिवाइस पंजीकरण का पासवर्ड उपलब्ध नहीं है",
|
||||||
|
"Reverse tunnel SSH public key was not found": "टनल की सार्वजनिक SSH कुंजी नहीं मिली",
|
||||||
|
"Reverse tunnel enrollment request failed": "टनल सेटअप अनुरोध विफल हुआ",
|
||||||
"Security & Region": "सुरक्षा और क्षेत्र",
|
"Security & Region": "सुरक्षा और क्षेत्र",
|
||||||
"WEB UI account security, recovery, and regional time settings.": "WEB UI खाता सुरक्षा, पहुँच पुनर्प्राप्ति और क्षेत्रीय समय सेटिंग्स।",
|
"WEB UI account security, recovery, and regional time settings.": "WEB UI खाता सुरक्षा, पहुँच पुनर्प्राप्ति और क्षेत्रीय समय सेटिंग्स।",
|
||||||
"Region and time zone": "क्षेत्र और समय क्षेत्र",
|
"Region and time zone": "क्षेत्र और समय क्षेत्र",
|
||||||
|
|
|
||||||
|
|
@ -283,7 +283,8 @@
|
||||||
},
|
},
|
||||||
reverseTunnelUi: {
|
reverseTunnelUi: {
|
||||||
openGroups: {},
|
openGroups: {},
|
||||||
bootstrapOpen: false
|
bootstrapOpen: false,
|
||||||
|
configuring: false
|
||||||
},
|
},
|
||||||
theme: "light",
|
theme: "light",
|
||||||
language: "en",
|
language: "en",
|
||||||
|
|
@ -1317,6 +1318,7 @@
|
||||||
{ name: "webui", label: "Edge Console", href: `http://${host}:8099` }
|
{ name: "webui", label: "Edge Console", href: `http://${host}:8099` }
|
||||||
];
|
];
|
||||||
const restartBusy = !!state.serviceActions.busyById[card.id];
|
const restartBusy = !!state.serviceActions.busyById[card.id];
|
||||||
|
const configuring = state.reverseTunnelUi.configuring;
|
||||||
|
|
||||||
return `
|
return `
|
||||||
<article class="panel card serviceCard reverseTunnelCard">
|
<article class="panel card serviceCard reverseTunnelCard">
|
||||||
|
|
@ -1347,7 +1349,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="list">
|
<div class="list">
|
||||||
<div class="formHint">
|
<div class="formHint">
|
||||||
${esc(t("Reverse Tunnel is needed for remote access from outside the local network. If you already have access to this UI, you are already on the same network as the Edge device, so Reverse Tunnel is usually not needed. To use it later, open Web UI, go to Devices, select your Edge device, then open the SSH tab in device settings. The required links and the full 2-step instructions are there."))}
|
${esc(t("Configure remote access using the saved device registration. If setup was skipped or failed, try again here without registering the device again. Each click makes one attempt."))}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
${bootstrapCommand ? `
|
${bootstrapCommand ? `
|
||||||
|
|
@ -1380,7 +1382,10 @@
|
||||||
<div class="list">
|
<div class="list">
|
||||||
<div class="listTitle">${esc(t("Actions"))}</div>
|
<div class="listTitle">${esc(t("Actions"))}</div>
|
||||||
<div class="actionRow serviceActionRow">
|
<div class="actionRow serviceActionRow">
|
||||||
<button class="actionBtn secondary" type="button" ${restartBusy ? "disabled" : ""} onclick="window.__restartService('${esc(card.id)}')">
|
<button class="actionBtn" type="button" ${restartBusy || configuring ? "disabled" : ""} onclick="window.__configureReverseTunnel()">
|
||||||
|
${esc(configuring ? t("Configuring...") : t("Configure"))}
|
||||||
|
</button>
|
||||||
|
<button class="actionBtn secondary" type="button" ${restartBusy || configuring ? "disabled" : ""} onclick="window.__restartService('${esc(card.id)}')">
|
||||||
${esc(restartBusy ? t("Restarting...") : t("Restart"))}
|
${esc(restartBusy ? t("Restarting...") : t("Restart"))}
|
||||||
</button>
|
</button>
|
||||||
${tunnelLinks.map((link) => {
|
${tunnelLinks.map((link) => {
|
||||||
|
|
@ -5125,6 +5130,7 @@
|
||||||
|
|
||||||
window.__restartService = async function (serviceId) {
|
window.__restartService = async function (serviceId) {
|
||||||
if (!serviceId || state.serviceActions.busyById[serviceId]) return;
|
if (!serviceId || state.serviceActions.busyById[serviceId]) return;
|
||||||
|
if (serviceId === "reverse_tunnel" && state.reverseTunnelUi.configuring) return;
|
||||||
state.serviceActions.busyById[serviceId] = true;
|
state.serviceActions.busyById[serviceId] = true;
|
||||||
if (state.activeTab === "health") renderActiveTab();
|
if (state.activeTab === "health") renderActiveTab();
|
||||||
try {
|
try {
|
||||||
|
|
@ -5167,6 +5173,25 @@
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
window.__configureReverseTunnel = async function () {
|
||||||
|
if (state.reverseTunnelUi.configuring || state.serviceActions.busyById.reverse_tunnel) return;
|
||||||
|
state.reverseTunnelUi.configuring = true;
|
||||||
|
if (state.activeTab === "health") renderActiveTab();
|
||||||
|
try {
|
||||||
|
const payload = await fetchJson("/api/itscreen/reverse-tunnel/configure", {
|
||||||
|
method: "POST",
|
||||||
|
cache: "no-store"
|
||||||
|
});
|
||||||
|
showToast("success", translateUiText(payload.message));
|
||||||
|
await loadHealth();
|
||||||
|
} catch (error) {
|
||||||
|
showToast("error", translateUiText(error.message || "Reverse tunnel setup failed. Check the tunnel services and try again."));
|
||||||
|
} finally {
|
||||||
|
state.reverseTunnelUi.configuring = false;
|
||||||
|
if (state.activeTab === "health") renderActiveTab();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
window.__toggleTunnelGroup = function (groupKey) {
|
window.__toggleTunnelGroup = function (groupKey) {
|
||||||
if (!groupKey) return;
|
if (!groupKey) return;
|
||||||
state.reverseTunnelUi.openGroups[groupKey] = !state.reverseTunnelUi.openGroups[groupKey];
|
state.reverseTunnelUi.openGroups[groupKey] = !state.reverseTunnelUi.openGroups[groupKey];
|
||||||
|
|
|
||||||
|
|
@ -108,7 +108,7 @@
|
||||||
</main>
|
</main>
|
||||||
<div id="menuBackdrop" class="menuBackdrop" hidden></div>
|
<div id="menuBackdrop" class="menuBackdrop" hidden></div>
|
||||||
<div id="toastStack" class="toastStack" aria-live="polite" aria-atomic="true"></div>
|
<div id="toastStack" class="toastStack" aria-live="polite" aria-atomic="true"></div>
|
||||||
<script src="/console.i18n.js?v=2.2.80"></script>
|
<script src="/console.i18n.js?v=2.2.81"></script>
|
||||||
<script src="/console.js?v=2.2.80"></script>
|
<script src="/console.js?v=2.2.81"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue