Working on an authoritative online game using LiteNetLib. I've been reading about building a game network protocol and I'm feeling stuck with the "challenge" implementation.

  • The client requests a connection with the server.
  • The server then returns some sort of challenge (that only the client should be able to solve?).
  • The client returns the solution and the server allows the connection.

The first thing that I don't get is how to have a "pending" connection without accepting it to begin with. With LiteNetLib, this is how the server handles incoming connections:

listener.ConnectionRequestEvent += request =>
    if(server.ConnectedPeersCount < 10 /* max connections */)

From the looks of it, the server must decide whether to allow the client or not at this very instant. If I want to send or receive a challenge, I need to accept the connection first don't I? But that would defeat the point of the challenge implementation.

Is there a resource with an example of how this is done? The article doesn't really go into detail, and when I google things like "online game protocol challenge request packet" the results aren't quite related (almost as if the concept was coined by that article).

  • \$\begingroup\$ The challenge just needs to be any random, unpredictable value that an attacker couldn't realistically guess. The reason it's a "challenge" is because the server is sending that information to the client's IP and port, so if an attacker is using a spoofed IP, they won't receive the challenge packet from the server because it will go to whoever actually owns that IP address. It's the same as sending someone a verification email when they sign up for a website. You can sign up with someone else's email address trivially, but you won't be able to verify unless you can actually read their email. \$\endgroup\$
    – Dan
    Jul 31 '21 at 4:45

You must log in to answer this question.

Browse other questions tagged .