adding delays

This commit is contained in:
2026-03-08 19:00:33 -04:00
parent 7ef0528361
commit 3cb3c9ccb7

View File

@@ -2,10 +2,14 @@
asyncio TCP server — connection handler with SO_ORIGINAL_DST support.
"""
import asyncio
import random
import socket
import struct
from typing import Optional
_DELAY_MIN = 0.2 # seconds
_DELAY_MAX = 2.0 # seconds
from .config import Config
from .logger import Logger
@@ -58,6 +62,7 @@ async def _handle(
if banner:
writer.write(banner)
await writer.drain()
await asyncio.sleep(random.uniform(_DELAY_MIN, _DELAY_MAX))
except (ConnectionResetError, BrokenPipeError):
pass
finally: