browser address schema update (#2931)
This commit is contained in:
@@ -103,18 +103,6 @@ def close_all_sessions() -> None:
|
|||||||
print(f"Error closing sessions: {str(e)}")
|
print(f"Error closing sessions: {str(e)}")
|
||||||
|
|
||||||
|
|
||||||
async def direct_get_network_info(session_id: str) -> None:
|
|
||||||
"""Get network info directly from PersistentSessionsManager"""
|
|
||||||
try:
|
|
||||||
manager = app.PERSISTENT_SESSIONS_MANAGER
|
|
||||||
cdp_port, ip_address = await manager.get_network_info(session_id)
|
|
||||||
print("\nNetwork info:")
|
|
||||||
print(f" CDP Port: {cdp_port}")
|
|
||||||
print(f" IP Address: {ip_address}")
|
|
||||||
except Exception as e:
|
|
||||||
print(f"Error getting network info: {str(e)}")
|
|
||||||
|
|
||||||
|
|
||||||
async def direct_list_sessions(organization_id: str) -> None:
|
async def direct_list_sessions(organization_id: str) -> None:
|
||||||
"""List sessions directly from PersistentSessionsManager"""
|
"""List sessions directly from PersistentSessionsManager"""
|
||||||
try:
|
try:
|
||||||
@@ -143,11 +131,6 @@ async def handle_direct_command(cmd: str, args: list[str]) -> None:
|
|||||||
"""Handle direct method calls"""
|
"""Handle direct method calls"""
|
||||||
if cmd == "help_direct":
|
if cmd == "help_direct":
|
||||||
print_direct_help()
|
print_direct_help()
|
||||||
elif cmd == "direct_network":
|
|
||||||
if not args:
|
|
||||||
print("Error: session_id required")
|
|
||||||
return
|
|
||||||
await direct_get_network_info(args[0])
|
|
||||||
elif cmd == "direct_list":
|
elif cmd == "direct_list":
|
||||||
if not args:
|
if not args:
|
||||||
print("Error: organization_id required")
|
print("Error: organization_id required")
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ Streaming VNC WebSocket connections.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
import structlog
|
import structlog
|
||||||
import websockets
|
import websockets
|
||||||
@@ -169,7 +170,9 @@ async def loop_stream_vnc(streaming: sc.Streaming) -> None:
|
|||||||
return
|
return
|
||||||
|
|
||||||
browser_address = streaming.browser_session.browser_address
|
browser_address = streaming.browser_session.browser_address
|
||||||
host, _ = browser_address.rsplit(":")
|
|
||||||
|
parsed_browser_address = urlparse(browser_address)
|
||||||
|
host = parsed_browser_address.hostname
|
||||||
vnc_url = f"ws://{host}:{streaming.vnc_port}"
|
vnc_url = f"ws://{host}:{streaming.vnc_port}"
|
||||||
|
|
||||||
LOG.info(
|
LOG.info(
|
||||||
|
|||||||
@@ -16,8 +16,6 @@ LOG = structlog.get_logger()
|
|||||||
@dataclass
|
@dataclass
|
||||||
class BrowserSession:
|
class BrowserSession:
|
||||||
browser_state: BrowserState
|
browser_state: BrowserState
|
||||||
cdp_port: int
|
|
||||||
cdp_host: str = "localhost"
|
|
||||||
|
|
||||||
|
|
||||||
class PersistentSessionsManager:
|
class PersistentSessionsManager:
|
||||||
@@ -139,16 +137,6 @@ class PersistentSessionsManager:
|
|||||||
organization_id=organization_id,
|
organization_id=organization_id,
|
||||||
)
|
)
|
||||||
|
|
||||||
async def get_network_info(self, session_id: str) -> tuple[int | None, str | None]:
|
|
||||||
"""Returns cdp port and ip address of the browser session"""
|
|
||||||
browser_session = self._browser_sessions.get(session_id)
|
|
||||||
if browser_session:
|
|
||||||
return (
|
|
||||||
browser_session.cdp_port,
|
|
||||||
browser_session.cdp_host,
|
|
||||||
)
|
|
||||||
return None, None
|
|
||||||
|
|
||||||
async def release_browser_session(self, session_id: str, organization_id: str) -> None:
|
async def release_browser_session(self, session_id: str, organization_id: str) -> None:
|
||||||
"""Release a specific browser session."""
|
"""Release a specific browser session."""
|
||||||
await self.database.release_persistent_browser_session(session_id, organization_id)
|
await self.database.release_persistent_browser_session(session_id, organization_id)
|
||||||
|
|||||||
Reference in New Issue
Block a user