
import socket
import concurrent.futures

CANDIDATES = [
    "ritm001.rithmic.com",
    "ritm002.rithmic.com",
    "ritm003.rithmic.com",
    "ritm004.rithmic.com",
    "ritm005.rithmic.com",
    "paper.rithmic.com",
    "test.rithmic.com",
    "cert.rithmic.com",
    "rithmic.com",
    "www.rithmic.com",
    "us-east-1.rithmic.com",
    "us-east-2.rithmic.com",
    "chicago.rithmic.com",
    "aurora.rithmic.com",
    "frankfurt.rithmic.com",
    "tokyo.rithmic.com",
    "sin.rithmic.com"
]

PORTS = [80, 443, 56000, 65000, 16000, 10000]

def check_connection(host, port):
    try:
        sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        sock.settimeout(1.0)
        result = sock.connect_ex((host, port))
        sock.close()
        if result == 0:
            return f"{host}:{port} -> OPEN"
    except:
        pass
    return None

def scan():
    print("Scanning Rithmic servers...")
    with concurrent.futures.ThreadPoolExecutor(max_workers=20) as executor:
        futures = []
        for host in CANDIDATES:
            for port in PORTS:
                futures.append(executor.submit(check_connection, host, port))
        
        for future in concurrent.futures.as_completed(futures):
            res = future.result()
            if res:
                print(res)
    print("Scan finished.")

if __name__ == "__main__":
    scan()
