SimpleSallap:SimpleMCP:Try identify https in http mode early
Else python default http code will try interpret it has a malformed http request line and give failure lines like * bad version number * bad http/0.9 request etal along with a long bytes string following it
This commit is contained in:
parent
e04afaa6ff
commit
e67734fa22
|
|
@ -76,6 +76,10 @@ class Network(DictyDataclassMixin):
|
||||||
class Op(DictyDataclassMixin):
|
class Op(DictyDataclassMixin):
|
||||||
"""
|
"""
|
||||||
Used to store runtime operation related config entries and states
|
Used to store runtime operation related config entries and states
|
||||||
|
|
||||||
|
Attributes:
|
||||||
|
sslContext: stores ssl context to use,
|
||||||
|
indirectly indicate if using https mode or not
|
||||||
"""
|
"""
|
||||||
configFile: str = "/dev/null"
|
configFile: str = "/dev/null"
|
||||||
debug: bool = False
|
debug: bool = False
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,8 @@ import time
|
||||||
import ssl
|
import ssl
|
||||||
import traceback
|
import traceback
|
||||||
import json
|
import json
|
||||||
|
import select
|
||||||
|
import socket
|
||||||
from typing import Any
|
from typing import Any
|
||||||
from dataclasses import asdict
|
from dataclasses import asdict
|
||||||
import tcpdf as mTCPdf
|
import tcpdf as mTCPdf
|
||||||
|
|
@ -197,6 +199,13 @@ class ProxyHandler(http.server.BaseHTTPRequestHandler):
|
||||||
if (gMe.op.sslContext):
|
if (gMe.op.sslContext):
|
||||||
self.request = gMe.op.sslContext.wrap_socket(self.request, server_side=True)
|
self.request = gMe.op.sslContext.wrap_socket(self.request, server_side=True)
|
||||||
self.setup()
|
self.setup()
|
||||||
|
else:
|
||||||
|
conn: socket.socket = self.connection
|
||||||
|
readReady, _, _ = select.select([conn], [], [], 1.0)
|
||||||
|
if readReady:
|
||||||
|
peek = conn.recv(3, socket.MSG_PEEK)
|
||||||
|
if peek.startswith(b'\x16\x03'):
|
||||||
|
raise ConnectionError("Https in http mode???")
|
||||||
except:
|
except:
|
||||||
print(f"ERRR:ProxyHandler:SSLHS:{traceback.format_exception_only(sys.exception())}")
|
print(f"ERRR:ProxyHandler:SSLHS:{traceback.format_exception_only(sys.exception())}")
|
||||||
return
|
return
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue