Browse Source

Replace hardcoded 192.168.5.4 with ms.e-bash.ru:2223

- Frontend: use window.location.origin for iframe URLs
- Backend: dynamic WebSocket URL based on client location
- Update default tunnel server to ms.e-bash.ru:2223
- Fix DevicesView.vue defaults

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
root 2 weeks ago
parent
commit
f9be24af27

+ 6 - 4
backend/app/api/v1/superadmin/tunnels.py

@@ -176,8 +176,8 @@ async def enable_tunnel(
 
 
     # Copy other tunnel settings from default
     # Copy other tunnel settings from default
     if "server" not in device.config[tunnel_key]:
     if "server" not in device.config[tunnel_key]:
-        device.config[tunnel_key]["server"] = "192.168.5.4"
-        device.config[tunnel_key]["port"] = 22
+        device.config[tunnel_key]["server"] = "ms.e-bash.ru"
+        device.config[tunnel_key]["port"] = 2223
         device.config[tunnel_key]["user"] = "tunnel"
         device.config[tunnel_key]["user"] = "tunnel"
         device.config[tunnel_key]["keepalive_interval"] = 30
         device.config[tunnel_key]["keepalive_interval"] = 30
 
 
@@ -562,12 +562,14 @@ async def tunnel_terminal_html(
             import re
             import re
             # Find WebSocket URL construction in JavaScript
             # Find WebSocket URL construction in JavaScript
             ws_before = html.count('new WebSocket')
             ws_before = html.count('new WebSocket')
+            # Use wss:// for HTTPS, ws:// for HTTP - construct from request would be ideal
+            # For now, replace with relative WebSocket that browser will resolve
             html = re.sub(
             html = re.sub(
                 r'(new WebSocket\([\'"])(ws[s]?://[^/]+)(/ws[\'"])',
                 r'(new WebSocket\([\'"])(ws[s]?://[^/]+)(/ws[\'"])',
-                rf'\1ws://192.168.5.4:8000{prefix}\3',
+                rf"\1' + (location.protocol === 'https:' ? 'wss://' : 'ws://') + location.host + '{prefix}\3",
                 html
                 html
             )
             )
-            ws_after = html.count('ws://192.168.5.4:8000')
+            ws_after = html.count("location.host")
             print(f"[tunnel] HTML: replaced {ws_after} WebSocket URLs (found {ws_before} total)")
             print(f"[tunnel] HTML: replaced {ws_after} WebSocket URLs (found {ws_before} total)")
 
 
             from starlette.responses import HTMLResponse
             from starlette.responses import HTMLResponse

+ 4 - 4
backend/app/default_config.json

@@ -17,8 +17,8 @@
   },
   },
   "ssh_tunnel": {
   "ssh_tunnel": {
     "enabled": false,
     "enabled": false,
-    "server": "192.168.5.4",
-    "port": 22,
+    "server": "ms.e-bash.ru",
+    "port": 2223,
     "user": "tunnel",
     "user": "tunnel",
     "remote_port": 0,
     "remote_port": 0,
     "keepalive_interval": 30,
     "keepalive_interval": 30,
@@ -26,8 +26,8 @@
   },
   },
   "dashboard_tunnel": {
   "dashboard_tunnel": {
     "enabled": false,
     "enabled": false,
-    "server": "192.168.5.4",
-    "port": 22,
+    "server": "ms.e-bash.ru",
+    "port": 2223,
     "user": "tunnel",
     "user": "tunnel",
     "remote_port": 0,
     "remote_port": 0,
     "keepalive_interval": 30,
     "keepalive_interval": 30,

+ 1 - 1
frontend/src/views/admin/TunnelDashboard.vue

@@ -32,7 +32,7 @@ async function loadDashboard() {
 
 
     if (status.status === 'ready' && status.device_tunnel_port) {
     if (status.status === 'ready' && status.device_tunnel_port) {
       // Backend proxies dashboard through tunnel
       // Backend proxies dashboard through tunnel
-      dashboardUrl.value = `http://192.168.5.4:8000/api/v1/superadmin/tunnels/sessions/${sessionUuid}/dashboard/`
+      dashboardUrl.value = `${window.location.origin}/api/v1/superadmin/tunnels/sessions/${sessionUuid}/dashboard/`
       loading.value = false
       loading.value = false
 
 
       // Start heartbeat
       // Start heartbeat

+ 1 - 1
frontend/src/views/admin/TunnelTerminal.vue

@@ -32,7 +32,7 @@ async function loadTerminal() {
 
 
     if (status.status === 'ready' && status.ttyd_port) {
     if (status.status === 'ready' && status.ttyd_port) {
       // Backend проксирует WebSocket на localhost ttyd
       // Backend проксирует WebSocket на localhost ttyd
-      ttydUrl.value = `http://192.168.5.4:8000/api/v1/superadmin/tunnels/sessions/${sessionUuid}/terminal`
+      ttydUrl.value = `${window.location.origin}/api/v1/superadmin/tunnels/sessions/${sessionUuid}/terminal`
       loading.value = false
       loading.value = false
 
 
       // Start heartbeat
       // Start heartbeat

+ 4 - 4
frontend/src/views/superadmin/DevicesView.vue

@@ -541,16 +541,16 @@ const defaultConfig = ref({
   },
   },
   ssh_tunnel: {
   ssh_tunnel: {
     enabled: false,
     enabled: false,
-    server: '192.168.5.4',
-    port: 22,
+    server: 'ms.e-bash.ru',
+    port: 2223,
     user: 'tunnel',
     user: 'tunnel',
     remote_port: 0,
     remote_port: 0,
     keepalive_interval: 30
     keepalive_interval: 30
   },
   },
   dashboard_tunnel: {
   dashboard_tunnel: {
     enabled: false,
     enabled: false,
-    server: '192.168.5.4',
-    port: 22,
+    server: 'ms.e-bash.ru',
+    port: 2223,
     user: 'tunnel',
     user: 'tunnel',
     remote_port: 0,
     remote_port: 0,
     keepalive_interval: 30
     keepalive_interval: 30