[Loginserver] Code Cleanup and Tweaks (#1653)

* if for whatever reason the world server is not sending an address, use the local address it sends

* Log when world is sending loginserver info

* Force legacy mode when login host is login.eqemulator.net to avoid misconfigurations at least until things change

* Add human IP translation to log messages

* Sanitize world server name

* Code cleanup and renaming member variables

* More cleanup

* Remove this->

* Validation constants

* Key worldserver lookups by both longname and shortname both

* Update allowed character list

* Fix short_name API response field; add world_id to response

* Shorten receiver verbosity

* Remove unnecessary member variables from database and rename database to m_database

* Adjust MAX_SERVER_VERSION_LENGTH

* Fix indents
This commit is contained in:
Chris Miles
2021-10-30 19:09:42 -05:00
committed by GitHub
parent 119c3d14b7
commit d87db648c3
27 changed files with 496 additions and 870 deletions
+28
View File
@@ -605,3 +605,31 @@ std::string FormatName(const std::string& char_name)
}
return formatted;
}
bool IsAllowedWorldServerCharacterList(char c)
{
const char *valid_characters = ":[](){}.!@#$%^&*-=+<>/\\|'\"";
if (strchr(valid_characters, c)) {
return true;
}
return false;
}
void SanitizeWorldServerName(char *name)
{
std::string server_long_name = name;
server_long_name.erase(
std::remove_if(
server_long_name.begin(),
server_long_name.end(),
[](char c) {
return !(std::isalpha(c) || std::isalnum(c) || std::isspace(c) || IsAllowedWorldServerCharacterList(c));
}
), server_long_name.end()
);
server_long_name = trim(server_long_name);
strcpy(name, server_long_name.c_str());
}