Implement DNS caching and verbose logging
All checks were successful
Build and Release / Build Windows Exe (push) Successful in 10s

This commit is contained in:
2026-02-06 16:33:13 -05:00
parent 9e7e4054c4
commit dcddd88cbc
2 changed files with 15 additions and 3 deletions

View File

@@ -1,6 +1,8 @@
import socket
from typing import Optional
from functools import lru_cache
@lru_cache(maxsize=1024)
def get_hostname(ip: str) -> Optional[str]:
try:
# Python's equivalent to Resolv.getname(ip)
@@ -9,6 +11,7 @@ def get_hostname(ip: str) -> Optional[str]:
except socket.error:
return None
@lru_cache(maxsize=1024)
def get_ip(hostname: str) -> Optional[str]:
try:
return socket.gethostbyname(hostname)