about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/APIv1.py10
-rw-r--r--src/socks.py9
2 files changed, 11 insertions, 8 deletions
diff --git a/src/APIv1.py b/src/APIv1.py
index a3254aa..7304e87 100644
--- a/src/APIv1.py
+++ b/src/APIv1.py
@@ -59,7 +59,7 @@ def decode_size(size: str) -> int:
     return size
 
 
-async def respond(client: SSLSocket, request: Request) -> tuple[int, bytes]:
+async def respond(client: SSLSocket, request: Request) -> tuple[int, bytes, dict]:
     """
     Respond to clients API request
     """
@@ -78,10 +78,10 @@ async def respond(client: SSLSocket, request: Request) -> tuple[int, bytes]:
 
             # check size
             if size < API_FILE_RANDOM_MIN_SIZE_LIMIT or size > API_FILE_RANDOM_MAX_SIZE_LIMIT:
-                return 400, b''
+                return 400, b'', {}
 
-            return 200, random_data_gen(size)
+            return 200, random_data_gen(size), {}
         else:
-            return 400, b''
+            return 400, b'', {}
     else:
-        return 400, b''
+        return 400, b'', {}
diff --git a/src/socks.py b/src/socks.py
index 119a62a..bcb76c0 100644
--- a/src/socks.py
+++ b/src/socks.py
@@ -1,18 +1,21 @@
-import time
+import asyncio
 from ssl import SSLSocket
 
 
+_SOCK_TIME_DELAY = 1.e-3
+
+
 async def ssl_sock_accept(sock: SSLSocket) -> tuple[SSLSocket, str]:
     while True:
         try:
             return sock.accept()
         except BlockingIOError:
-            time.sleep(1.e-3)
+            await asyncio.sleep(_SOCK_TIME_DELAY)
 
 
 async def ssl_sock_recv(sock: SSLSocket, buflen: int = 1024):
     while (msg := sock.recv(buflen)) == b'':
-        time.sleep(1.e-3)
+        await asyncio.sleep(_SOCK_TIME_DELAY)
     return msg