Add support for Valve style authentication, fixes #106

This commit is contained in:
Tiiffi
2024-11-07 14:37:45 +02:00
parent accae57e4b
commit aa933d2c1f
4 changed files with 13 additions and 3 deletions

View File

@ -1,5 +1,8 @@
#### Version history:
###### 0.7.3
- Add support to Valve style rcon authentication
###### 0.7.2
- Quit gracefully when Ctrl-D or Ctrl+C is pressed
- Remove "exit" and "quit" as quitting commands

View File

@ -18,4 +18,3 @@ freely, subject to the following restrictions:
3. This notice may not be removed or altered from any source
distribution.

View File

@ -1,7 +1,7 @@
.\" Process this file with
.\" groff -man -Tascii mcrcon.1
.\"
.TH MCRCON 1 "October 2021" "Version 0.7.2"
.TH MCRCON 1 "November 2024" "Version 0.7.3"
.SH NAME
mcrcon \- send rcon commands to a Minecraft server
.SH SYNOPSIS

View File

@ -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;
}