mirror of
https://github.com/Flowseal/tg-ws-proxy.git
synced 2026-10-30 22:56:59 +03:00
some ai powered fixes for #1473
This commit is contained in:
1 parent
7fb01a7d05
commit
44c5ee2a57
2 files changed
+41
-4
No files matched your search
+8
-4
@@ -284,17 +284,21 @@ async def probe_appdata_len(domain: str, port: int = 443,
|
||||
pass
|
||||
client_hello = outgoing.read()
|
||||
|
||||
# Share one deadline across connecting, sending, and reading the flight.
|
||||
loop = asyncio.get_running_loop()
|
||||
deadline = loop.time() + timeout
|
||||
reader, writer = await asyncio.wait_for(
|
||||
asyncio.open_connection(domain, port), timeout=timeout)
|
||||
writer.write(client_hello)
|
||||
await writer.drain()
|
||||
await asyncio.wait_for(writer.drain(), timeout=deadline - loop.time())
|
||||
|
||||
flight = bytearray()
|
||||
loop = asyncio.get_running_loop()
|
||||
deadline = loop.time() + timeout
|
||||
while True:
|
||||
remaining = deadline - loop.time()
|
||||
if remaining <= 0:
|
||||
raise asyncio.TimeoutError
|
||||
chunk = await asyncio.wait_for(
|
||||
reader.read(16384), timeout=max(0.1, deadline - loop.time()))
|
||||
reader.read(16384), timeout=remaining)
|
||||
if not chunk:
|
||||
return None
|
||||
flight.extend(chunk)
|
||||
|
||||
Reference in new issue
Block a user