mirror of
https://github.com/bunny-lab-io/Borealis.git
synced 2025-10-26 23:41:58 -06:00
Fix Socket.IO TLS alignment
This commit is contained in:
@@ -848,6 +848,25 @@ class AgentHttpClient:
|
|||||||
if engine is None:
|
if engine is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
http_iface = getattr(engine, "http", None)
|
||||||
|
|
||||||
|
def _set_attr(target: Any, name: str, value: Any) -> None:
|
||||||
|
if target is None:
|
||||||
|
return
|
||||||
|
try:
|
||||||
|
setattr(target, name, value)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
|
def _reset_cached_session() -> None:
|
||||||
|
if http_iface is None:
|
||||||
|
return
|
||||||
|
try:
|
||||||
|
if hasattr(http_iface, "session"):
|
||||||
|
setattr(http_iface, "session", None)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
context = None
|
context = None
|
||||||
if isinstance(verify, str) and os.path.isfile(verify):
|
if isinstance(verify, str) and os.path.isfile(verify):
|
||||||
try:
|
try:
|
||||||
@@ -857,27 +876,26 @@ class AgentHttpClient:
|
|||||||
context = None
|
context = None
|
||||||
|
|
||||||
if context is not None:
|
if context is not None:
|
||||||
try:
|
_set_attr(engine, "ssl_context", context)
|
||||||
engine.ssl_context = context
|
_set_attr(engine, "ssl_verify", True)
|
||||||
except Exception:
|
_set_attr(engine, "verify_ssl", True)
|
||||||
pass
|
_set_attr(http_iface, "ssl_context", context)
|
||||||
try:
|
_set_attr(http_iface, "ssl_verify", True)
|
||||||
engine.ssl_verify = True
|
_set_attr(http_iface, "verify_ssl", True)
|
||||||
except Exception:
|
_reset_cached_session()
|
||||||
pass
|
|
||||||
return
|
return
|
||||||
|
|
||||||
# Fall back to boolean verification flags when we either do not
|
# Fall back to boolean verification flags when we either do not
|
||||||
# have a pinned certificate bundle or failed to build a dedicated
|
# have a pinned certificate bundle or failed to build a dedicated
|
||||||
# context for it.
|
# context for it.
|
||||||
try:
|
verify_flag = False if verify is False else True
|
||||||
engine.ssl_context = None
|
_set_attr(engine, "ssl_context", None)
|
||||||
except Exception:
|
_set_attr(engine, "ssl_verify", verify_flag)
|
||||||
pass
|
_set_attr(engine, "verify_ssl", verify_flag)
|
||||||
try:
|
_set_attr(http_iface, "ssl_context", None)
|
||||||
engine.ssl_verify = False if verify is False else True
|
_set_attr(http_iface, "ssl_verify", verify_flag)
|
||||||
except Exception:
|
_set_attr(http_iface, "verify_ssl", verify_flag)
|
||||||
pass
|
_reset_cached_session()
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@@ -2373,6 +2391,17 @@ async def connect():
|
|||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@sio.event
|
||||||
|
async def connect_error(data):
|
||||||
|
try:
|
||||||
|
setattr(sio, "connection_error", data)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
_log_agent(f'Socket connect_error event: {data!r}', fname='agent.error.log')
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
@sio.event
|
@sio.event
|
||||||
async def disconnect():
|
async def disconnect():
|
||||||
print("[WebSocket] Disconnected from Borealis server.")
|
print("[WebSocket] Disconnected from Borealis server.")
|
||||||
|
|||||||
Reference in New Issue
Block a user