Change to username:password for reserved slots

This is a more common syntax.
This commit is contained in:
heinrich5991 2023-06-02 19:55:27 +02:00
parent 2d3221492d
commit ebacc0fb96

View file

@ -1377,13 +1377,17 @@ bool CServer::CheckReservedSlotAuth(int ClientID, const char *pPassword)
return true;
}
// "^#(.*?)#(.*)$"
if(Config()->m_SvReservedSlotsAuthLevel != 4 && pPassword[0] == '#')
// "^([^:]*):(.*)$"
if(Config()->m_SvReservedSlotsAuthLevel != 4)
{
char aName[sizeof(Config()->m_Password)];
const char *pPass = str_next_token(pPassword + 1, "#", aName, sizeof(aName));
const char *pInnerPassword = str_next_token(pPassword, ":", aName, sizeof(aName));
if(!pInnerPassword)
{
return false;
}
int Slot = m_AuthManager.FindKey(aName);
if(pPass && m_AuthManager.CheckKey(Slot, pPass + 1) && m_AuthManager.KeyLevel(Slot) >= Config()->m_SvReservedSlotsAuthLevel)
if(m_AuthManager.CheckKey(Slot, pInnerPassword + 1) && m_AuthManager.KeyLevel(Slot) >= Config()->m_SvReservedSlotsAuthLevel)
{
str_format(aBuf, sizeof(aBuf), "cid=%d joining reserved slot with key=%s", ClientID, m_AuthManager.KeyIdent(Slot));
Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", aBuf);