INNER CODE UNIT · Python

listen

paulveillard/cybersecurity · cyber-security-scripts/Simple_Anti_DDoS.py:41

def listen():
    while True:
        accept_conn = True
        global connections
        global max_conn
        global conn_msg
        global stopped_midway
        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        s.bind((servip, port))
        if connections < max_conn:
            if accept_conn:
                s.listen(1)
                conn, ip = s.accept()
                print("[+]", ip, "has connected.")
                if connections <= max_conn and ip_conn not in blacklist:
                    print("[+] Connection to server accepted.")
                elif connections <= max_conn and ip_conn in blacklist:
                    conn.shutdown(1)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…