This commit is contained in:
ciomek committed 2026-09-19 20:39:12 +02:00
1 parent b954d9d448
commit b2bd4d25f9
20 files changed
+804 -170

No files matched your search

+4 -4
View File
@@ -11,12 +11,12 @@ class Discover:
CLIENT_TIMEOUT = 2
@staticmethod
def listen(real_port, host="0.0.0.0"):
def listen(real_port, host="0.0.0.0", discover_port=None):
logger = get_logger(Discover.__name__)
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.bind((host, Discover.DISCOVER_PORT))
s.bind((host, discover_port or Discover.DISCOVER_PORT))
s.listen()
while True:
@@ -36,8 +36,8 @@ class Discover:
logger.debug(f"Discovery request failed: {e}")
@staticmethod
def request(target_host, timeout=3):
with socket.create_connection((target_host, Discover.DISCOVER_PORT), timeout=timeout) as s:
def request(target_host, timeout=3, discover_port=None):
with socket.create_connection((target_host, discover_port or Discover.DISCOVER_PORT), timeout=timeout) as s:
s.sendall(Discover.MAGIC)
data = b""