Merge remote-tracking branch 'warmachine/master'

This commit is contained in:
CodeCodeon
2015-10-20 02:12:52 -05:00
committed by CodeCodon
3245 changed files with 657027 additions and 4 deletions
@@ -110,6 +110,7 @@ include_directories(
${SWG_EXTERNALS_SOURCE_DIR}/3rd/library/platform/projects
${SWG_EXTERNALS_SOURCE_DIR}/3rd/library/platform/utils
${SWG_EXTERNALS_SOURCE_DIR}/3rd/library/udplibrary
${CURL_INCLUDE_DIRS}
)
add_executable(LoginServer
@@ -151,4 +152,5 @@ target_link_libraries(LoginServer
LoginAPI
MonAPI2
${CMAKE_DL_LIBS}
${CURL_LIBRARIES}
)
@@ -24,6 +24,7 @@
#include "sharedNetworkMessages/LoginEnumCluster.h"
#include <algorithm>
#include "curl/curl.h"
//-----------------------------------------------------------------------
@@ -171,7 +172,15 @@ void ClientConnection::onReceive(const Archive::ByteStream & message)
//-----------------------------------------------------------------------
// Stub routine for station API account validation.
// Grab a challenge key from the list and send it back to the client.
static size_t WriteCallback(void *contents, size_t size, size_t nmemb, void *userp)
{
((std::string*)userp)->append((char*)contents, size * nmemb);
return size * nmemb;
}
void ClientConnection::validateClient(const std::string & id, const std::string & key)
{
if (ConfigLoginServer::getValidateStationKey())
@@ -202,10 +211,46 @@ void ClientConnection::validateClient(const std::string & id, const std::string
LOG("LoginClientConnection", ("validateClient() for stationId (%lu) at IP (%s), id (%s) key (%s), skipping validating session", m_stationId, getRemoteAddress().c_str(), id.c_str(), key.c_str()));
LoginServer::getInstance().onValidateClient(suid, id, this, true, NULL, 0xFFFFFFFF, 0xFFFFFFFF);
if (ConfigLoginServer::getAuthentication() == false)
{
LoginServer::getInstance().onValidateClient(suid, id, this, true, NULL, 0xFFFFFFFF, 0xFFFFFFFF);
}
CURL *curl;
CURLcode res;
std::string readBuffer;
curl = curl_easy_init();
if (curl)
{
std::string username(curl_easy_escape(curl, id.c_str(), id.length()));
std::string password(curl_easy_escape(curl, key.c_str(), key.length()));
curl_easy_setopt(curl, CURLOPT_URL, ("phpauthurl" + username + "&pw=" + password).c_str());
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer);
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
if (ConfigLoginServer::getAuthentication() == true)
{
if(readBuffer == "1")
{
LoginServer::getInstance().onValidateClient(suid, id, this, true, NULL, 0xFFFFFFFF, 0xFFFFFFFF);
}
else if(readBuffer == "2")
{
ErrorMessage err("Login Failed", "Banned");
this->send(err, true);
}
else
{
ErrorMessage err("Login Failed", "Invalid Username or Password");
this->send(err, true);
}
}
}
}
}
// ----------------------------------------------------------------------------
/**
@@ -114,6 +114,7 @@ void ConfigLoginServer::install(void)
KEY_INT (populationLightThresholdPercent, 8);
KEY_INT (csToolPort, 10666);
KEY_BOOL(requireSecureLoginForCsTool, true);
KEY_BOOL(authentication, false);
int index = 0;
char const * result = 0;
@@ -65,6 +65,7 @@ class ConfigLoginServer
int csToolPort;
bool requireSecureLoginForCsTool;
bool authentication;
};
static const uint16 getCentralServicePort();
@@ -126,6 +127,7 @@ class ConfigLoginServer
static int getPopulationHeavyThresholdPercent();
static int getPopulationMediumThresholdPercent();
static int getPopulationLightThresholdPercent();
static bool getAuthentication();
// has character creation for this cluster been disabled through config option
static bool isCharacterCreationDisabled(std::string const & cluster);
@@ -467,6 +469,11 @@ inline const int ConfigLoginServer::getCSToolPort()
{
return data->csToolPort;
}
inline bool ConfigLoginServer::getAuthentication()
{
return data->authentication;
}
// ======================================================================
#endif // _ConfigLoginServer_H