feat: add timer
Signed-off-by: Tuan-Dat Tran <tuan-dat.tran@dextradata.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import math
|
||||
import re
|
||||
import socket
|
||||
import time
|
||||
|
||||
|
||||
HOST = "challenge01.root-me.org"
|
||||
@@ -22,7 +23,9 @@ def solve_prompt(prompt: str) -> str:
|
||||
|
||||
|
||||
def main() -> None:
|
||||
with socket.create_connection((HOST, PORT), timeout=2) as conn:
|
||||
conn = socket.create_connection((HOST, PORT), timeout=2)
|
||||
start_time = time.monotonic()
|
||||
try:
|
||||
prompt = conn.recv(4096).decode(errors="replace")
|
||||
print(prompt, end="")
|
||||
|
||||
@@ -31,6 +34,10 @@ def main() -> None:
|
||||
|
||||
result = conn.recv(4096).decode(errors="replace")
|
||||
print(result, end="")
|
||||
finally:
|
||||
conn.close()
|
||||
elapsed = time.monotonic() - start_time
|
||||
print(f"\nConnection lifetime: {elapsed:.3f}s")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user