From 9c5ade24da0dc7e285db659767bdd092e55a2cf0 Mon Sep 17 00:00:00 2001 From: eeeee Date: Tue, 6 Jun 2017 19:45:42 -0700 Subject: [PATCH] remove ConDnsblStatus copypasta --- src/engine/server/server.cpp | 55 ++++++++---------------------------- src/engine/server/server.h | 2 ++ 2 files changed, 13 insertions(+), 44 deletions(-) diff --git a/src/engine/server/server.cpp b/src/engine/server/server.cpp index c00298f03..4a6e42076 100644 --- a/src/engine/server/server.cpp +++ b/src/engine/server/server.cpp @@ -1995,7 +1995,7 @@ void CServer::ConKick(IConsole::IResult *pResult, void *pUser) ((CServer *)pUser)->Kick(pResult->GetInteger(0), "Kicked by console"); } -void CServer::ConStatus(IConsole::IResult *pResult, void *pUser) +void CServer::StatusImpl(IConsole::IResult *pResult, void *pUser, bool DnsblBlacklistedOnly) { char aBuf[1024]; char aAddrStr[NETADDR_MAXSTRSIZE]; @@ -2005,7 +2005,10 @@ void CServer::ConStatus(IConsole::IResult *pResult, void *pUser) for(int i = 0; i < MAX_CLIENTS; i++) { - if(pThis->m_aClients[i].m_State != CClient::STATE_EMPTY) + if( + pThis->m_aClients[i].m_State != CClient::STATE_EMPTY + && (!DnsblBlacklistedOnly || pThis->m_aClients[i].m_DnsblState == CClient::DNSBL_STATE_BLACKLISTED) + ) { net_addr_str(pThis->m_NetServer.ClientAddr(i), aAddrStr, sizeof(aAddrStr), true); if(pThis->m_aClients[i].m_State == CClient::STATE_INGAME) @@ -2032,55 +2035,19 @@ void CServer::ConStatus(IConsole::IResult *pResult, void *pUser) else str_format(aBuf, sizeof(aBuf), "id=%d connecting", i); } - pThis->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "Server", aBuf); } } } +void CServer::ConStatus(IConsole::IResult *pResult, void *pUser) +{ + StatusImpl(pResult, pUser, false); +} + void CServer::ConDnsblStatus(IConsole::IResult *pResult, void *pUser) { - // dump blacklisted clients - char aBuf[1024]; - char aAddrStr[NETADDR_MAXSTRSIZE]; - CServer *pThis = static_cast(pUser); - - bool CanSeeAddress = pThis->m_aClients[pResult->m_ClientID].m_Authed > CServer::AUTHED_MOD; - - for(int i = 0; i < MAX_CLIENTS; i++) - { - if(pThis->m_aClients[i].m_State != CClient::STATE_EMPTY && - pThis->m_aClients[i].m_DnsblState == CClient::DNSBL_STATE_BLACKLISTED) - { - net_addr_str(pThis->m_NetServer.ClientAddr(i), aAddrStr, sizeof(aAddrStr), true); - if(pThis->m_aClients[i].m_State == CClient::STATE_INGAME) - { - const char *pAuthStr = pThis->m_aClients[i].m_Authed == CServer::AUTHED_ADMIN ? "(Admin)" : - pThis->m_aClients[i].m_Authed == CServer::AUTHED_MOD ? "(Mod)" : - pThis->m_aClients[i].m_Authed == CServer::AUTHED_HELPER ? "(Helper)" : ""; - char aAuthStr[128]; - aAuthStr[0] = '\0'; - if(pThis->m_aClients[i].m_AuthKey >= 0) - str_format(aAuthStr, sizeof(aAuthStr), "key=%s %s", pThis->m_AuthManager.KeyIdent(pThis->m_aClients[i].m_AuthKey), pAuthStr); - - if (CanSeeAddress) - str_format(aBuf, sizeof(aBuf), "id=%d addr=%s name='%s' score=%d client=%d secure=%s %s", i, aAddrStr, - pThis->m_aClients[i].m_aName, pThis->m_aClients[i].m_Score, pThis->GameServer()->GetClientVersion(i), pThis->m_NetServer.HasSecurityToken(i) ? "yes" : "no", aAuthStr); - else - str_format(aBuf, sizeof(aBuf), "id=%d name='%s' score=%d client=%d secure=%s %s", i, - pThis->m_aClients[i].m_aName, pThis->m_aClients[i].m_Score, pThis->GameServer()->GetClientVersion(i), pThis->m_NetServer.HasSecurityToken(i) ? "yes" : "no", aAuthStr); - } - else - { - if (CanSeeAddress) - str_format(aBuf, sizeof(aBuf), "id=%d addr=%s connecting", i, aAddrStr); - else - str_format(aBuf, sizeof(aBuf), "id=%d connecting", i); - } - - pThis->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "Server", aBuf); - } - } + StatusImpl(pResult, pUser, true); } static int GetAuthLevel(const char *pLevel) diff --git a/src/engine/server/server.h b/src/engine/server/server.h index 794412e25..439266abd 100644 --- a/src/engine/server/server.h +++ b/src/engine/server/server.h @@ -299,6 +299,8 @@ public: static void ConAuthRemove(IConsole::IResult *pResult, void *pUser); static void ConAuthList(IConsole::IResult *pResult, void *pUser); + static void StatusImpl(IConsole::IResult *pResult, void *pUser, bool DnsblBlacklistedOnly); + #if defined (CONF_SQL) // console commands for sqlmasters static void ConAddSqlServer(IConsole::IResult *pResult, void *pUserData);