Promovat Reclama ta aici
Membru Începător
Membru Începător
Mesaje: 2
Membru din: 01 Noi 2026, 18:37
  • Reacții: 31
  • Mesaje utile: 0
  • Status: Turning ideas into code.
  • Regat: Jinno
  • [ID Discord]
  • Medalii

    *Descriere:
    DynCast Handshake Guard
    C++23 | Connection limits | Handshake validation

    Hi everyone,

    I'm sharing a new handshake guard for the server source. It controls how many connections can enter, how long they can stay in the handshake phase and what data they are allowed to send before reaching login.

    First, I'd like to thank Owsap for the time he put into Improved Handshake Process and for sharing it with the community back in 2021. Contributions like that give other developers something to learn from and build on. His tutorial was the starting point for this project, and I wanted to take the idea further.

    What the original tutorial does

    Owsap's implementation tracks handshake timing and repeated connection attempts from each IP. It uses the server's pulse counter and host vectors to identify repeated attempts, count them and temporarily block an address once the configured threshold is reached. It also checks the blocked-IP state while processing incoming data.

    That covers connection spam from individual addresses. This version expands the checks to cover resource usage, incomplete handshakes and malformed packets as well.

    What this version adds

    Separate limits for each IP and the whole process
    Token buckets allow short connection bursts while controlling the sustained connection rate. Pending handshakes and total active connections have their own limits, both per IP and per process. Completing a handshake frees its pending slot, but the active connection remains counted until it is destroyed.

    Bounded address tracking
    The address table has a configurable maximum size. Old, inactive entries are removed in small batches, while entries still used by connections are kept. If the table is full, new addresses are refused instead of letting it grow indefinitely.

    A fixed handshake deadline
    The default is five seconds from admission, measured with a monotonic clock. Sending a few bytes at a time or repeated PONG packets does not restart that timer. There are also separate limits on the total bytes and complete frames accepted during the handshake.

    Packet checks before parsing
    Only the expected pre-authentication packet types are accepted. Fixed-size messages must declare their exact size, and variable-length TEXT commands are checked within their frame boundaries. Incomplete frames wait for the remaining bytes; invalid headers or lengths are rejected before the body is handled.

    Temporary penalties without kicking established players
    Repeated malformed frames, invalid key proofs or exceeded byte/frame budgets can trigger an escalating cooldown. Ordinary disconnects and timeouts do not add an IP penalty. Attempts made during a cooldown do not extend it, and a later cooldown does not kick players already connected from the same IP. No permanent automatic bans are written.

    Connection slots are released correctly
    A move-only lease follows the connection through setup, completion, failure and destruction. This keeps the counters consistent when setup fails or a connection disappears halfway through the handshake. Admission checks still happen before allocating the descriptor and generating its keys.

    Integration fixes and useful counters
    The integration removes a double socket-close path, bounds the TEXT command parser and checks key-completion errors before allowing the connection to enter login/auth. Rejections and handshake failures are counted by reason and reported in aggregate, rather than adding a new log entry for every rejected attempt.

    Source used and compatibility

    The source used for development and testing is Distraught's M2Dev Advanced Files:
    View Distraught's source release

    The integration targets that source's 16-bit packet headers, 16-bit frame lengths and existing libsodium key exchange. The encryption protocol stays the same. On this base, the tutorial only changes the server Game source, including the executable used for auth. No client, pack, quest or database changes are needed.

    Classic sources with one-byte packet headers need an adapted integration. The supplied instructions should not be pasted into a different protocol unchanged. A compiler and standard library supporting the C++23 features used by the code are required.

    Installation

    The archive contains the complete new source files, file-by-file Search for / Replace with, add the new files, apply the edits and rebuild Game.

    If you already use the old Improved Handshake Process tutorial, remove its hooks before installing this one. The limits are configurable and apply to each process separately, so tune them for your login bursts, status checks and players sharing an IP.

    This guards the application's connection and handshake paths. It does not replace network-level DDoS protection.

    Credits
    Owsap - Improved Handshake Process and the original idea.
    Distraught - the source release used for development and testing.
    DynCast - Handshake Guard implementation and integration.

    *Poze / Video (obligatoriu):
    Not requested, only code.
    *Link download:
    MediaFire
    Conținut: Ascuns
    Reacționează ❤️ la acest mesaj și conținutul se va afișa automat.


    TeraBox
    Conținut: Ascuns
    Reacționează ❤️ la acest mesaj și conținutul se va afișa automat.
    *Link scanare VirusTotal (obligatoriu):
    Fii primul care reacționează
    ✦ **DynCast** | Metin2 Systems Development

    C++ • Python • Custom Systems • Developer Tools

    🌐 https://dyncast.dev/
    Promovat Reclama ta aici

    Înapoi la “Sisteme Metin2”

    Informații

    Utilizatori ce navighează pe acest forum: jawwadsex, mt2classic, Nikolaos Safaridis, strumfy, uakkes și 20 de vizitatori

    Discord ID copiat:
    Promovat Reclama ta aici