rcon: use correct packet type for auth responses
This commit is contained in:
+1
-1
@@ -160,7 +160,7 @@ int rcon_authenticate(int sockfd, const char *password) {
|
||||
|
||||
printf("received auth packet: id=%d, type=%d\n", response.id, response.type);
|
||||
|
||||
if (response.type != RCON_SERVERDATA_RESPONSE_VALUE) {
|
||||
if (response.type != RCON_SERVERDATA_AUTH_RESPONSE) {
|
||||
fprintf(stderr, "authentication failed - unexpected initial packet type: %d\n", response.type);
|
||||
return -1;
|
||||
}
|
||||
|
||||
+3
-2
@@ -1,9 +1,10 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#define RCON_SERVERDATA_AUTH 3
|
||||
#define RCON_SERVERDATA_AUTH_RESPONSE 2
|
||||
#define RCON_SERVERDATA_EXECCOMMAND 2
|
||||
#define RCON_SERVERDATA_AUTH 3
|
||||
|
||||
#define RCON_SERVERDATA_RESPONSE_VALUE 0
|
||||
#define RCON_SERVERDATA_AUTH_RESPONSE 2
|
||||
|
||||
typedef struct {
|
||||
// size of the remainder of the packet
|
||||
|
||||
+3
-4
@@ -162,7 +162,6 @@ static void test_authenticate_successful_flow(void **state) {
|
||||
|
||||
const char *password = "hunter2";
|
||||
|
||||
send_raw_packet(sockets.server, 1, RCON_SERVERDATA_RESPONSE_VALUE, "");
|
||||
send_raw_packet(sockets.server, 1, RCON_SERVERDATA_AUTH_RESPONSE, "");
|
||||
|
||||
assert_int_equal(rcon_authenticate(sockets.client, password), 0);
|
||||
@@ -178,7 +177,7 @@ static void test_authenticate_invalid_password(void **state) {
|
||||
|
||||
const char *password = "wrong-password";
|
||||
|
||||
send_raw_packet(sockets.server, -1, RCON_SERVERDATA_RESPONSE_VALUE, "");
|
||||
send_raw_packet(sockets.server, -1, RCON_SERVERDATA_AUTH_RESPONSE, "");
|
||||
|
||||
assert_int_equal(rcon_authenticate(sockets.client, password), -1);
|
||||
receive_auth_response(sockets.server, password);
|
||||
@@ -193,7 +192,7 @@ static void test_authenticate_unexpected_packet_type(void **state) {
|
||||
|
||||
const char *password = "hunter2";
|
||||
|
||||
send_raw_packet(sockets.server, 1, RCON_SERVERDATA_EXECCOMMAND, "");
|
||||
send_raw_packet(sockets.server, 1, RCON_SERVERDATA_RESPONSE_VALUE, "");
|
||||
|
||||
assert_int_equal(rcon_authenticate(sockets.client, password), -1);
|
||||
receive_auth_response(sockets.server, password);
|
||||
@@ -208,7 +207,7 @@ static void test_authenticate_mismatched_response_id(void **state) {
|
||||
|
||||
const char *password = "hunter2";
|
||||
|
||||
send_raw_packet(sockets.server, 2, RCON_SERVERDATA_RESPONSE_VALUE, "");
|
||||
send_raw_packet(sockets.server, 2, RCON_SERVERDATA_AUTH_RESPONSE, "");
|
||||
|
||||
assert_int_equal(rcon_authenticate(sockets.client, password), -1);
|
||||
receive_auth_response(sockets.server, password);
|
||||
|
||||
Reference in New Issue
Block a user