mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Add playerflags, dnsbl, and ips for non-admins in status
This commit is contained in:
parent
d72929d33b
commit
a7ef921e3f
|
@ -146,6 +146,7 @@ public:
|
|||
virtual void SetClientClan(int ClientID, char const *pClan) = 0;
|
||||
virtual void SetClientCountry(int ClientID, int Country) = 0;
|
||||
virtual void SetClientScore(int ClientID, int Score) = 0;
|
||||
virtual void SetClientFlags(int ClientID, int Flags) = 0;
|
||||
|
||||
virtual int SnapNewID() = 0;
|
||||
virtual void SnapFreeID(int ID) = 0;
|
||||
|
|
|
@ -256,6 +256,7 @@ void CServer::CClient::Reset()
|
|||
m_SnapRate = CClient::SNAPRATE_INIT;
|
||||
m_Score = 0;
|
||||
m_NextMapChunk = 0;
|
||||
m_Flags = 0;
|
||||
}
|
||||
|
||||
CServer::CServer()
|
||||
|
@ -407,6 +408,15 @@ void CServer::SetClientScore(int ClientID, int Score)
|
|||
m_aClients[ClientID].m_Score = Score;
|
||||
}
|
||||
|
||||
void CServer::SetClientFlags(int ClientID, int Flags)
|
||||
{
|
||||
if(ClientID < 0 || ClientID >= MAX_CLIENTS || m_aClients[ClientID].m_State < CClient::STATE_READY)
|
||||
return;
|
||||
|
||||
if(Flags > m_aClients[ClientID].m_Flags)
|
||||
m_aClients[ClientID].m_Flags = Flags;
|
||||
}
|
||||
|
||||
void CServer::Kick(int ClientID, const char *pReason)
|
||||
{
|
||||
if(ClientID < 0 || ClientID >= MAX_CLIENTS || m_aClients[ClientID].m_State == CClient::STATE_EMPTY)
|
||||
|
@ -2119,60 +2129,53 @@ void CServer::ConKick(IConsole::IResult *pResult, void *pUser)
|
|||
((CServer *)pUser)->Kick(pResult->GetInteger(0), "Kicked by console");
|
||||
}
|
||||
|
||||
void CServer::StatusImpl(IConsole::IResult *pResult, void *pUser, bool DnsblBlacklistedOnly)
|
||||
void CServer::ConStatus(IConsole::IResult *pResult, void *pUser)
|
||||
{
|
||||
char aBuf[1024];
|
||||
char aAddrStr[NETADDR_MAXSTRSIZE];
|
||||
CServer *pThis = static_cast<CServer *>(pUser);
|
||||
|
||||
bool CanSeeAddress = pThis->m_aClients[pResult->m_ClientID].m_Authed > AUTHED_MOD;
|
||||
|
||||
for(int i = 0; i < MAX_CLIENTS; i++)
|
||||
{
|
||||
if(
|
||||
pThis->m_aClients[i].m_State != CClient::STATE_EMPTY
|
||||
&& (!DnsblBlacklistedOnly || pThis->m_aClients[i].m_DnsblState == CClient::DNSBL_STATE_BLACKLISTED)
|
||||
)
|
||||
{
|
||||
if(pThis->m_aClients[i].m_State == CClient::STATE_EMPTY)
|
||||
continue;
|
||||
|
||||
net_addr_str(pThis->m_NetServer.ClientAddr(i), aAddrStr, sizeof(aAddrStr), true);
|
||||
if(pThis->m_aClients[i].m_State == CClient::STATE_INGAME)
|
||||
{
|
||||
char aDnsblStr[64];
|
||||
aDnsblStr[0] = '\0';
|
||||
if(g_Config.m_SvDnsbl)
|
||||
{
|
||||
const char *pDnsblStr = pThis->m_aClients[i].m_DnsblState == CClient::DNSBL_STATE_WHITELISTED ? "white" :
|
||||
pThis->m_aClients[i].m_DnsblState == CClient::DNSBL_STATE_BLACKLISTED ? "black" :
|
||||
pThis->m_aClients[i].m_DnsblState == CClient::DNSBL_STATE_PENDING ? "pending" : "n/a";
|
||||
|
||||
str_format(aDnsblStr, sizeof(aDnsblStr), " dnsbl=%s", pDnsblStr);
|
||||
}
|
||||
|
||||
char aAuthStr[128];
|
||||
aAuthStr[0] = '\0';
|
||||
if(pThis->m_aClients[i].m_AuthKey >= 0)
|
||||
{
|
||||
const char *pAuthStr = pThis->m_aClients[i].m_Authed == AUTHED_ADMIN ? "(Admin)" :
|
||||
pThis->m_aClients[i].m_Authed == AUTHED_MOD ? "(Mod)" :
|
||||
pThis->m_aClients[i].m_Authed == 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);
|
||||
str_format(aAuthStr, sizeof(aAuthStr), " key=%s %s", pThis->m_AuthManager.KeyIdent(pThis->m_aClients[i].m_AuthKey), pAuthStr);
|
||||
}
|
||||
|
||||
str_format(aBuf, sizeof(aBuf), "id=%d addr='%s' name='%s' client=%d secure=%s flags=%d%s%s",
|
||||
i, aAddrStr, pThis->m_aClients[i].m_aName, pThis->GameServer()->GetClientVersion(i),
|
||||
pThis->m_NetServer.HasSecurityToken(i) ? "yes" : "no", pThis->m_aClients[i].m_Flags, aDnsblStr, 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CServer::ConStatus(IConsole::IResult *pResult, void *pUser)
|
||||
{
|
||||
StatusImpl(pResult, pUser, false);
|
||||
}
|
||||
|
||||
void CServer::ConDnsblStatus(IConsole::IResult *pResult, void *pUser)
|
||||
{
|
||||
StatusImpl(pResult, pUser, true);
|
||||
}
|
||||
|
||||
static int GetAuthLevel(const char *pLevel)
|
||||
{
|
||||
|
@ -2821,8 +2824,6 @@ void CServer::RegisterCommands()
|
|||
Console()->Register("dump_sqlservers", "s['r'|'w']", CFGFLAG_SERVER, ConDumpSqlServers, this, "dumps all sqlservers readservers = r, writeservers = w");
|
||||
#endif
|
||||
|
||||
Console()->Register("dnsbl_status", "", CFGFLAG_SERVER, ConDnsblStatus, this, "List blacklisted players");
|
||||
|
||||
Console()->Register("auth_add", "s[ident] s[level] s[pw]", CFGFLAG_SERVER|CFGFLAG_NONTEEHISTORIC, ConAuthAdd, this, "Add a rcon key");
|
||||
Console()->Register("auth_add_p", "s[ident] s[level] s[hash] s[salt]", CFGFLAG_SERVER|CFGFLAG_NONTEEHISTORIC, ConAuthAddHashed, this, "Add a prehashed rcon key");
|
||||
Console()->Register("auth_change", "s[ident] s[level] s[pw]", CFGFLAG_SERVER|CFGFLAG_NONTEEHISTORIC, ConAuthUpdate, this, "Update a rcon key");
|
||||
|
|
|
@ -167,6 +167,7 @@ public:
|
|||
int m_AuthKey;
|
||||
int m_AuthTries;
|
||||
int m_NextMapChunk;
|
||||
int m_Flags;
|
||||
|
||||
const IConsole::CCommandInfo *m_pRconCmdToSend;
|
||||
|
||||
|
@ -236,6 +237,7 @@ public:
|
|||
virtual void SetClientClan(int ClientID, char const *pClan);
|
||||
virtual void SetClientCountry(int ClientID, int Country);
|
||||
virtual void SetClientScore(int ClientID, int Score);
|
||||
virtual void SetClientFlags(int ClientID, int Flags);
|
||||
|
||||
void Kick(int ClientID, const char *pReason);
|
||||
void Ban(int ClientID, int Seconds, const char *pReason);
|
||||
|
@ -314,7 +316,6 @@ public:
|
|||
static void ConStopRecord(IConsole::IResult *pResult, void *pUser);
|
||||
static void ConMapReload(IConsole::IResult *pResult, void *pUser);
|
||||
static void ConLogout(IConsole::IResult *pResult, void *pUser);
|
||||
static void ConDnsblStatus(IConsole::IResult *pResult, void *pUser);
|
||||
|
||||
static void ConAuthAdd(IConsole::IResult *pResult, void *pUser);
|
||||
static void ConAuthAddHashed(IConsole::IResult *pResult, void *pUser);
|
||||
|
@ -327,8 +328,6 @@ public:
|
|||
static void ConNameUnban(IConsole::IResult *pResult, void *pUser);
|
||||
static void ConNameBans(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);
|
||||
|
|
|
@ -429,6 +429,9 @@ void CPlayer::OnPredictedInput(CNetObj_PlayerInput *NewInput)
|
|||
|
||||
void CPlayer::OnDirectInput(CNetObj_PlayerInput *NewInput)
|
||||
{
|
||||
if(NewInput->m_PlayerFlags)
|
||||
Server()->SetClientFlags(m_ClientID, NewInput->m_PlayerFlags);
|
||||
|
||||
if(AfkTimer(NewInput->m_TargetX, NewInput->m_TargetY))
|
||||
return; // we must return if kicked, as player struct is already deleted
|
||||
AfkVoteTimer(NewInput);
|
||||
|
|
Loading…
Reference in a new issue