mirror of
https://github.com/Tiiffi/mcrcon.git
synced 2025-10-27 11:21:07 -04:00
Add support for Valve style authentication, fixes #106
This commit is contained in:
@ -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
|
||||
|
||||
1
LICENSE
1
LICENSE
@ -18,4 +18,3 @@ freely, subject to the following restrictions:
|
||||
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
|
||||
2
mcrcon.1
2
mcrcon.1
@ -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
|
||||
|
||||
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