#!/usr/bin/env python3
import socket
import threading
import time


SERVICES = [
    ("192.168.20.10", 25565, b"Minecraft SRV1\n"),
    ("192.168.20.10", 22, b"SSH SRV1\n"),
    ("192.168.20.10", 8080, b"HTTP SRV1\n"),
    ("192.168.20.20", 25565, b"Other host\n"),
]


def serve(host: str, port: int, payload: bytes) -> None:
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
    sock.bind((host, port))
    sock.listen()
    while True:
        conn, _ = sock.accept()
        try:
            conn.sendall(payload)
        finally:
            conn.close()


if __name__ == "__main__":
    for host, port, payload in SERVICES:
        thread = threading.Thread(target=serve, args=(host, port, payload), daemon=True)
        thread.start()

    while True:
        time.sleep(3600)
