TEIL7
Folgendes wird geprüft/aufgerufen, wenn ein Spieler versucht dem Server beizutreten:
Spoiler anzeigen
Folgendes wird geprüft/aufgerufen, wenn ein Kommando der Mod in die Konsole eingegeben wird:
Spoiler anzeigen
Wenn Whitelist oder/und Blacklist ist/sind aktiv, verstecke die Spielernamen und den Clan der Spieler.
Bsp.:
Spoiler anzeigen
4.) Downloads
Bin:
Linux x86_64: file-upload.net/download-7308265/teeworlds_srv.zip.html
Linux x32: kommt...
Win32: noch nicht unterstützt, dazu oben mehr
Source:
config_variables.h: file-upload.net/download-7308266/config_variables.h.html
server.h: file-upload.net/download-7308267/server.h.html
server.cpp: file-upload.net/download-7308268/server.cpp.html
5.) Schlusswort
Falls jemand eine Idee zu dem "Problem" der Funktion "AutoDeleteTrustedIP" oder andere Vorschläge hat, bitte ich darum mir diese mitzuteilen.
Ansonsten bedanke ich mich für's lesen! :-)
Folgendes wird geprüft/aufgerufen, wenn ein Spieler versucht dem Server beizutreten:
[cpp]
// beginnend ab zeile 1307 in der Funktion "ProcessClientPacket"
CheckIfIPIsTrusted(Addr);
if(bPub_IPIsTrusted)
{
// ip is trusted, dont check white or blacklist
// player is allowed to join the game
// maybe player has new ip, check and save
SaveAndTrustIP(ClientID, Addr);
}
else
{
// whitelist
if(g_Config.m_SvWhiteList == 1)
{
CheckWhiteList(ClientID);
str_format(aBuf, sizeof(aBuf), "Whitelist is ON");
Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", aBuf);
}
else
{
str_format(aBuf, sizeof(aBuf), "Whitelist is OFF");
Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", aBuf);
}
// blacklist
if(g_Config.m_SvBlackList == 1)
{
CheckBlackList(ClientID);
str_format(aBuf, sizeof(aBuf), "Blacklist is ON");
Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", aBuf);
}
else
{
str_format(aBuf, sizeof(aBuf), "Blacklist is OFF");
Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", aBuf);
}
}
// check diferent variants of wl & bl
if(g_Config.m_SvWhiteList == 1 && g_Config.m_SvBlackList == 0) // only wl is on
{
if(bPub_PlayerIsOnWl)
{
SaveAndTrustIP(ClientID, Addr);
}
}
else if(g_Config.m_SvWhiteList == 0 && g_Config.m_SvBlackList == 1) // only bl is on
{
if(!bPub_PlayerIsOnBl)
{
SaveAndTrustIP(ClientID, Addr);
}
}
else if(g_Config.m_SvWhiteList == 1 && g_Config.m_SvBlackList == 1) // wl and bl are on
{
if(bPub_PlayerIsOnWl == true && bPub_PlayerIsOnBl == false)
{
SaveAndTrustIP(ClientID, Addr);
}
}
[/cpp]
// beginnend ab zeile 1307 in der Funktion "ProcessClientPacket"
CheckIfIPIsTrusted(Addr);
if(bPub_IPIsTrusted)
{
// ip is trusted, dont check white or blacklist
// player is allowed to join the game
// maybe player has new ip, check and save
SaveAndTrustIP(ClientID, Addr);
}
else
{
// whitelist
if(g_Config.m_SvWhiteList == 1)
{
CheckWhiteList(ClientID);
str_format(aBuf, sizeof(aBuf), "Whitelist is ON");
Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", aBuf);
}
else
{
str_format(aBuf, sizeof(aBuf), "Whitelist is OFF");
Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", aBuf);
}
// blacklist
if(g_Config.m_SvBlackList == 1)
{
CheckBlackList(ClientID);
str_format(aBuf, sizeof(aBuf), "Blacklist is ON");
Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", aBuf);
}
else
{
str_format(aBuf, sizeof(aBuf), "Blacklist is OFF");
Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", aBuf);
}
}
// check diferent variants of wl & bl
if(g_Config.m_SvWhiteList == 1 && g_Config.m_SvBlackList == 0) // only wl is on
{
if(bPub_PlayerIsOnWl)
{
SaveAndTrustIP(ClientID, Addr);
}
}
else if(g_Config.m_SvWhiteList == 0 && g_Config.m_SvBlackList == 1) // only bl is on
{
if(!bPub_PlayerIsOnBl)
{
SaveAndTrustIP(ClientID, Addr);
}
}
else if(g_Config.m_SvWhiteList == 1 && g_Config.m_SvBlackList == 1) // wl and bl are on
{
if(bPub_PlayerIsOnWl == true && bPub_PlayerIsOnBl == false)
{
SaveAndTrustIP(ClientID, Addr);
}
}
[/cpp]
Folgendes wird geprüft/aufgerufen, wenn ein Kommando der Mod in die Konsole eingegeben wird:
[cpp]
// auf zeile 1424
std::string spCmd = pCmd; // fix compiler warning
// beginnend ab zeile 1439
// whitelist add cmd sent (wl_add)
if(Unpacker.Error() == 0 && m_aClients[ClientID].m_Authed && spCmd.substr(0, 7) == "wl_add ")
{
char aBuf[256];
str_format(aBuf, sizeof(aBuf), "Trying to add '%s' to Whitelist...", g_Config.m_WlAdd);
Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "server", aBuf);
AddToWhiteList();
}
// whitelist remove cmd sent (wl_remove)
if(Unpacker.Error() == 0 && m_aClients[ClientID].m_Authed && spCmd.substr(0, 10) == "wl_remove ")
{
char aBuf[256];
str_format(aBuf, sizeof(aBuf), "Trying to remove '%s' from Whitelist...", g_Config.m_WlRemove);
Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "server", aBuf);
RemoveFromWhiteList();
}
// blacklist add cmd sent (bl_add)
if(Unpacker.Error() == 0 && m_aClients[ClientID].m_Authed && spCmd.substr(0, 7) == "bl_add ")
{
char aBuf[256];
str_format(aBuf, sizeof(aBuf), "Trying to add '%s' to Blacklist...", g_Config.m_BlAdd);
Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "server", aBuf);
AddToBlackList();
}
// blacklist remove cmd sent (bl_remove)
if(Unpacker.Error() == 0 && m_aClients[ClientID].m_Authed && spCmd.substr(0, 10) == "bl_remove ")
{
char aBuf[256];
str_format(aBuf, sizeof(aBuf), "Trying to remove '%s' from Blacklist...", g_Config.m_BlRemove);
Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "server", aBuf);
RemoveFromBlackList();
}
// remove ip from trusted ip list cmd sent (tr_ip_remove)
if(Unpacker.Error() == 0 && m_aClients[ClientID].m_Authed && spCmd.substr(0, 13) == "tr_ip_remove ")
{
char aBuf[256];
str_format(aBuf, sizeof(aBuf), "Trying to remove '%s' from trusted ip list...", g_Config.m_TrIPRemove);
Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "server", aBuf);
DeleteTrustedIP(-1, spCmd.substr(13, spCmd.length()-13));
}
[/cpp]
// auf zeile 1424
std::string spCmd = pCmd; // fix compiler warning
// beginnend ab zeile 1439
// whitelist add cmd sent (wl_add)
if(Unpacker.Error() == 0 && m_aClients[ClientID].m_Authed && spCmd.substr(0, 7) == "wl_add ")
{
char aBuf[256];
str_format(aBuf, sizeof(aBuf), "Trying to add '%s' to Whitelist...", g_Config.m_WlAdd);
Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "server", aBuf);
AddToWhiteList();
}
// whitelist remove cmd sent (wl_remove)
if(Unpacker.Error() == 0 && m_aClients[ClientID].m_Authed && spCmd.substr(0, 10) == "wl_remove ")
{
char aBuf[256];
str_format(aBuf, sizeof(aBuf), "Trying to remove '%s' from Whitelist...", g_Config.m_WlRemove);
Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "server", aBuf);
RemoveFromWhiteList();
}
// blacklist add cmd sent (bl_add)
if(Unpacker.Error() == 0 && m_aClients[ClientID].m_Authed && spCmd.substr(0, 7) == "bl_add ")
{
char aBuf[256];
str_format(aBuf, sizeof(aBuf), "Trying to add '%s' to Blacklist...", g_Config.m_BlAdd);
Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "server", aBuf);
AddToBlackList();
}
// blacklist remove cmd sent (bl_remove)
if(Unpacker.Error() == 0 && m_aClients[ClientID].m_Authed && spCmd.substr(0, 10) == "bl_remove ")
{
char aBuf[256];
str_format(aBuf, sizeof(aBuf), "Trying to remove '%s' from Blacklist...", g_Config.m_BlRemove);
Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "server", aBuf);
RemoveFromBlackList();
}
// remove ip from trusted ip list cmd sent (tr_ip_remove)
if(Unpacker.Error() == 0 && m_aClients[ClientID].m_Authed && spCmd.substr(0, 13) == "tr_ip_remove ")
{
char aBuf[256];
str_format(aBuf, sizeof(aBuf), "Trying to remove '%s' from trusted ip list...", g_Config.m_TrIPRemove);
Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "server", aBuf);
DeleteTrustedIP(-1, spCmd.substr(13, spCmd.length()-13));
}
[/cpp]
Wenn Whitelist oder/und Blacklist ist/sind aktiv, verstecke die Spielernamen und den Clan der Spieler.
Bsp.:
[cpp]
// beginnend ab zeile 1627 in der Funktion "SendServerInfo"
if(g_Config.m_SvWhiteList == 1 || g_Config.m_SvBlackList == 1) // if whitelist or blacklist is on (1), hide players and clans
{
p.AddString("Hidden Player", MAX_NAME_LENGTH);
p.AddString("Hidden Clan", MAX_CLAN_LENGTH);
}
else
{
for(i = 0; i < MAX_CLIENTS; i++)
{
if(m_aClients.m_State != CClient::STATE_EMPTY)
{
p.AddString(ClientName(i), MAX_NAME_LENGTH); // client name
p.AddString(ClientClan(i), MAX_CLAN_LENGTH); // client clan
str_format(aBuf, sizeof(aBuf), "%d", m_aClients.m_Country); p.AddString(aBuf, 6); // client country
str_format(aBuf, sizeof(aBuf), "%d", m_aClients.m_Score); p.AddString(aBuf, 6); // client score
str_format(aBuf, sizeof(aBuf), "%d", GameServer()->IsClientPlayer(i)?1:0); p.AddString(aBuf, 2); // is player?
}
}
}
[/cpp]
// beginnend ab zeile 1627 in der Funktion "SendServerInfo"
if(g_Config.m_SvWhiteList == 1 || g_Config.m_SvBlackList == 1) // if whitelist or blacklist is on (1), hide players and clans
{
p.AddString("Hidden Player", MAX_NAME_LENGTH);
p.AddString("Hidden Clan", MAX_CLAN_LENGTH);
}
else
{
for(i = 0; i < MAX_CLIENTS; i++)
{
if(m_aClients.m_State != CClient::STATE_EMPTY)
{
p.AddString(ClientName(i), MAX_NAME_LENGTH); // client name
p.AddString(ClientClan(i), MAX_CLAN_LENGTH); // client clan
str_format(aBuf, sizeof(aBuf), "%d", m_aClients.m_Country); p.AddString(aBuf, 6); // client country
str_format(aBuf, sizeof(aBuf), "%d", m_aClients.m_Score); p.AddString(aBuf, 6); // client score
str_format(aBuf, sizeof(aBuf), "%d", GameServer()->IsClientPlayer(i)?1:0); p.AddString(aBuf, 2); // is player?
}
}
}
[/cpp]
4.) Downloads
Bin:
Linux x86_64: file-upload.net/download-7308265/teeworlds_srv.zip.html
Linux x32: kommt...
Win32: noch nicht unterstützt, dazu oben mehr
Source:
config_variables.h: file-upload.net/download-7308266/config_variables.h.html
server.h: file-upload.net/download-7308267/server.h.html
server.cpp: file-upload.net/download-7308268/server.cpp.html
5.) Schlusswort
Falls jemand eine Idee zu dem "Problem" der Funktion "AutoDeleteTrustedIP" oder andere Vorschläge hat, bitte ich darum mir diese mitzuteilen.
Ansonsten bedanke ich mich für's lesen! :-)