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