mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Merge #6696
6696: Allow `username:password` for reserved slots r=Learath2 a=heinrich5991 This is a more common syntax. ## Checklist - [x] Tested the change ingame - [ ] Provided screenshots if it is a visual change - [x] Tested in combination with possibly related configuration options - [ ] Written a unit test (especially base/) or added coverage to integration test - [x] Considered possible null pointers and out of bounds array indexing - [ ] Changed no physics that affect existing maps - [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional) Co-authored-by: heinrich5991 <heinrich5991@gmail.com>
This commit is contained in:
commit
ffce094ba1
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue