Skip to main content
gamedev.net
🔒 Locked

Model Check

Started by Robinhood 2 replies 900+ views
Original Post
Robinhood
Robinhood
Hello,everyone.I am currently working on a tank game.The server part is made up of an account server,an database server which communicate with MySQL and some game servers. First clients connect to the account server to check the passwords,and then the account server sends MSG_GAME_NEWPLAYER to one game servers which are selected by players and sends MSG_CLIENT_PASS/MSG_CLIENT_FAILED to clients to indicate whether clients' passwords are valid.If the client's password is valid,he should reconnect to the game server(I don't think this is efficient).This is all about my work which currently have been done. How do you think about it?Can you give me some advice?
hplus0603
hplus0603
That sounds fairly standard.

How does the game server identify the client connecting? Just because he's saying he's using the same name as when checking the password? That's not very secure.

At the minimum, you should issue a random number to the client when it logs in, and tell the game server about the same random number. When the client connects to the game server, it supplies the random number to the game server; there would be a 1 in 4 billion chance that someone would guess the right number for the client in question (assuming 32-bit random numbers).


Another way to do it is to send name/password to the game server directly, and it verifies with the database back-end directly; that way, only a single connection needs to be established, but there's a little bit higher load on the game servers. Also, if the game servers are not trusted then this is less secure, as the password needs to pass through the game server.
enum Bool { True, False, FileNotFound };
Robinhood
Robinhood
How do I ensure that the random number is not already in use?
hplus0603
hplus0603
You don't necessarily need to care. You use the pair of "user name" and "random number" for your authentication, and that's what the server is looking for. If a player can only be logged in once at a time, well, only one random number is in use for that player at a time.

That being said, it's usually good to put a timeout on the validity of a authentication cookie like this, in the range of about a minute. If the player doesn't connect to the simulation server within a minute, he'll have to go back for a new cookie.

If you really want to assure identity, just keep a list of cookies you issued in the last half hour, and check each new cookie against the list; go back and try again if there's a collision. Four billion cookies is a LOT; you won't run out.

If you have multiple login servers, you probably want to make the login server identity part of the cookie, say, if you have up to 250 login servers, you make the top byte be the ID of the login server, and the next 24 bits are random (per server). But it doesn't sound like you need to scale that far.
enum Bool { True, False, FileNotFound };

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.