|
@@ -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
|