From 9c5200fec290b3f5d12d061fe8c9b62f1a411f98 Mon Sep 17 00:00:00 2001 From: rc4 Date: Wed, 22 Jun 2022 17:36:21 -0400 Subject: [PATCH] Fix authentication handling Add handling of empty SERVERDATA_RESPONSE_VALUE packet before SERVERDATA_AUTH_RESPONSE packet --- lib/Net/RCON.pm | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/Net/RCON.pm b/lib/Net/RCON.pm index 63608d3..ecd5c42 100644 --- a/lib/Net/RCON.pm +++ b/lib/Net/RCON.pm @@ -32,6 +32,12 @@ sub new { # Send a SERVERDATA_AUTH packet $object->_send_rcon( SERVERDATA_AUTH, $self->{password} ); + + # We should get an empty SERVERDATA_RESPONSE_VALUE packet first + if( !$self->_recv_rcon( SERVERDATA_RESPONSE_VALUE ) ) { + warn "Authentication to the RCON server failed - no reply from server"; + return undef; + } # Check is SERVERDATA_AUTH_RESPONSE came back as valid if( !$self->_recv_rcon( SERVERDATA_AUTH_RESPONSE ) ) {