Merge pull request #9220 from KebsCS/pr-rcon-auth-dummy

Auto rcon auth both main and dummy
This commit is contained in:
Dennis Felsing 2024-11-08 22:27:22 +00:00 committed by GitHub
commit b710f32a06
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 10 additions and 12 deletions

View file

@ -208,7 +208,7 @@ public:
virtual int *GetInput(int Tick, int IsDummy = 0) const = 0; virtual int *GetInput(int Tick, int IsDummy = 0) const = 0;
// remote console // remote console
virtual void RconAuth(const char *pUsername, const char *pPassword) = 0; virtual void RconAuth(const char *pUsername, const char *pPassword, bool Dummy) = 0;
virtual bool RconAuthed() const = 0; virtual bool RconAuthed() const = 0;
virtual bool UseTempRconCommands() const = 0; virtual bool UseTempRconCommands() const = 0;
virtual void Rcon(const char *pLine) = 0; virtual void Rcon(const char *pLine) = 0;

View file

@ -262,9 +262,9 @@ void CClient::SendMapRequest()
} }
} }
void CClient::RconAuth(const char *pName, const char *pPassword) void CClient::RconAuth(const char *pName, const char *pPassword, bool Dummy)
{ {
if(RconAuthed()) if(m_aRconAuthed[Dummy] != 0)
return; return;
if(pName != m_aRconUsername) if(pName != m_aRconUsername)
@ -276,7 +276,7 @@ void CClient::RconAuth(const char *pName, const char *pPassword)
{ {
CMsgPacker Msg7(protocol7::NETMSG_RCON_AUTH, true, true); CMsgPacker Msg7(protocol7::NETMSG_RCON_AUTH, true, true);
Msg7.AddString(pPassword); Msg7.AddString(pPassword);
SendMsgActive(&Msg7, MSGFLAG_VITAL); SendMsg(Dummy, &Msg7, MSGFLAG_VITAL);
return; return;
} }
@ -284,7 +284,7 @@ void CClient::RconAuth(const char *pName, const char *pPassword)
Msg.AddString(pName); Msg.AddString(pName);
Msg.AddString(pPassword); Msg.AddString(pPassword);
Msg.AddInt(1); Msg.AddInt(1);
SendMsgActive(&Msg, MSGFLAG_VITAL); SendMsg(Dummy, &Msg, MSGFLAG_VITAL);
} }
void CClient::Rcon(const char *pCmd) void CClient::Rcon(const char *pCmd)
@ -760,12 +760,7 @@ void CClient::DummyDisconnect(const char *pReason)
m_aNetClient[CONN_DUMMY].Disconnect(pReason); m_aNetClient[CONN_DUMMY].Disconnect(pReason);
g_Config.m_ClDummy = 0; g_Config.m_ClDummy = 0;
if(!m_aRconAuthed[0] && m_aRconAuthed[1])
{
RconAuth(m_aRconUsername, m_aRconPassword);
}
m_aRconAuthed[1] = 0; m_aRconAuthed[1] = 0;
m_aapSnapshots[1][SNAP_CURRENT] = 0; m_aapSnapshots[1][SNAP_CURRENT] = 0;
m_aapSnapshots[1][SNAP_PREV] = 0; m_aapSnapshots[1][SNAP_PREV] = 0;
m_aReceivedSnapshots[1] = 0; m_aReceivedSnapshots[1] = 0;
@ -1772,6 +1767,9 @@ void CClient::ProcessServerPacket(CNetChunk *pPacket, int Conn, bool Dummy)
if(!Unpacker.Error()) if(!Unpacker.Error())
{ {
m_aRconAuthed[Conn] = ResultInt; m_aRconAuthed[Conn] = ResultInt;
if(m_aRconAuthed[Conn])
RconAuth(m_aRconUsername, m_aRconPassword, g_Config.m_ClDummy ^ 1);
} }
if(Conn == CONN_MAIN) if(Conn == CONN_MAIN)
{ {

View file

@ -293,7 +293,7 @@ public:
bool RconAuthed() const override { return m_aRconAuthed[g_Config.m_ClDummy] != 0; } bool RconAuthed() const override { return m_aRconAuthed[g_Config.m_ClDummy] != 0; }
bool UseTempRconCommands() const override { return m_UseTempRconCommands != 0; } bool UseTempRconCommands() const override { return m_UseTempRconCommands != 0; }
void RconAuth(const char *pName, const char *pPassword) override; void RconAuth(const char *pName, const char *pPassword, bool Dummy = g_Config.m_ClDummy) override;
void Rcon(const char *pCmd) override; void Rcon(const char *pCmd) override;
bool ReceivingRconCommands() const override { return m_ExpectedRconCommands > 0; } bool ReceivingRconCommands() const override { return m_ExpectedRconCommands > 0; }
float GotRconCommandsPercentage() const override; float GotRconCommandsPercentage() const override;

View file

@ -310,7 +310,7 @@ void CGameConsole::CInstance::ExecuteLine(const char *pLine)
} }
else else
{ {
m_pGameConsole->Client()->RconAuth(m_aUser, pLine); m_pGameConsole->Client()->RconAuth(m_aUser, pLine, g_Config.m_ClDummy);
m_UserGot = false; m_UserGot = false;
} }
} }