mirror of
https://github.com/bunny-lab-io/Borealis.git
synced 2025-10-26 17:21:58 -06:00
Fix TLS noise and relocate server key material
This commit is contained in:
@@ -21,6 +21,7 @@ Section Guide:
|
||||
import os
|
||||
import sys
|
||||
from pathlib import Path
|
||||
import ssl
|
||||
|
||||
# Ensure the modular server package is importable when the runtime is launched
|
||||
# from a packaged directory (e.g., Server/Borealis). We look for the canonical
|
||||
@@ -41,6 +42,36 @@ eventlet.monkey_patch(thread=False)
|
||||
|
||||
from eventlet import tpool
|
||||
|
||||
try:
|
||||
from eventlet.wsgi import HttpProtocol # type: ignore
|
||||
except Exception:
|
||||
HttpProtocol = None # type: ignore[assignment]
|
||||
else:
|
||||
_original_handle_one_request = HttpProtocol.handle_one_request
|
||||
|
||||
def _quiet_tls_http_mismatch(self): # type: ignore[override]
|
||||
try:
|
||||
return _original_handle_one_request(self)
|
||||
except ssl.SSLError as exc: # type: ignore[arg-type]
|
||||
reason = getattr(exc, "reason", "")
|
||||
reason_text = str(reason).lower() if reason else ""
|
||||
message = " ".join(str(arg) for arg in exc.args if arg).lower()
|
||||
if "http_request" in message or reason_text == "http request":
|
||||
try:
|
||||
self.close_connection = True # type: ignore[attr-defined]
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
conn = getattr(self, "socket", None) or getattr(self, "connection", None)
|
||||
if conn:
|
||||
conn.close()
|
||||
except Exception:
|
||||
pass
|
||||
return None
|
||||
raise
|
||||
|
||||
HttpProtocol.handle_one_request = _quiet_tls_http_mismatch # type: ignore[assignment]
|
||||
|
||||
import requests
|
||||
import re
|
||||
import base64
|
||||
|
||||
Reference in New Issue
Block a user