mirror of
https://github.com/Tiiffi/mcrcon.git
synced 2025-10-28 03:41:07 -04:00
Add support for Valve style authentication, fixes #106
This commit is contained in:
10
mcrcon.c
10
mcrcon.c
@ -47,7 +47,7 @@
|
||||
#include <netdb.h>
|
||||
#endif
|
||||
|
||||
#define VERSION "0.7.2"
|
||||
#define VERSION "0.7.3"
|
||||
#define IN_NAME "mcrcon"
|
||||
#define VER_STR IN_NAME" "VERSION" (built: "__DATE__" "__TIME__")"
|
||||
|
||||
@ -595,10 +595,18 @@ int rcon_auth(int sock, char *passwd)
|
||||
if (!ret)
|
||||
return 0; // send failed
|
||||
|
||||
receive:
|
||||
packet = net_recv_packet(sock);
|
||||
if (packet == NULL)
|
||||
return 0;
|
||||
|
||||
/* Valve rcon sends empty "RCON_RESPONSEVALUE" packet before real auth response
|
||||
* so we have to check packet type and try again if necessary.
|
||||
*/
|
||||
if (packet->cmd != RCON_AUTH_RESPONSE) {
|
||||
goto receive;
|
||||
}
|
||||
|
||||
// return 1 if authentication OK
|
||||
return packet->id == -1 ? 0 : 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user