aboutsummaryrefslogtreecommitdiff
path: root/src/server/authserver
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/authserver')
-rw-r--r--src/server/authserver/Authentication/AuthCodes.cpp2
-rw-r--r--src/server/authserver/Authentication/TOTP.cpp6
-rw-r--r--src/server/authserver/Authentication/TOTP.h2
-rw-r--r--src/server/authserver/Main.cpp35
-rw-r--r--src/server/authserver/PrecompiledHeaders/authPCH.cpp17
-rw-r--r--src/server/authserver/PrecompiledHeaders/authPCH.h17
-rw-r--r--src/server/authserver/Server/AuthSession.cpp33
7 files changed, 78 insertions, 34 deletions
diff --git a/src/server/authserver/Authentication/AuthCodes.cpp b/src/server/authserver/Authentication/AuthCodes.cpp
index d0c41258130..4b6e78a72a3 100644
--- a/src/server/authserver/Authentication/AuthCodes.cpp
+++ b/src/server/authserver/Authentication/AuthCodes.cpp
@@ -77,6 +77,6 @@ namespace AuthHelper
if (PreBcAcceptedClientBuilds[i].Build == build)
return &PreBcAcceptedClientBuilds[i];
- return NULL;
+ return nullptr;
}
}
diff --git a/src/server/authserver/Authentication/TOTP.cpp b/src/server/authserver/Authentication/TOTP.cpp
index e26fd47e167..0566adea23a 100644
--- a/src/server/authserver/Authentication/TOTP.cpp
+++ b/src/server/authserver/Authentication/TOTP.cpp
@@ -18,7 +18,7 @@
#include "TOTP.h"
#include <cstring>
-int base32_decode(const char* encoded, char* result, int bufSize)
+int base32_decode(char const* encoded, char* result, int bufSize)
{
// Base32 implementation
// Copyright 2010 Google Inc.
@@ -68,7 +68,7 @@ int base32_decode(const char* encoded, char* result, int bufSize)
namespace TOTP
{
- unsigned int GenerateToken(const char* b32key)
+ unsigned int GenerateToken(char const* b32key)
{
size_t keySize = strlen(b32key);
int bufsize = (keySize + 7)/8*5;
@@ -76,7 +76,7 @@ namespace TOTP
memset(encoded, 0, bufsize);
unsigned int hmacResSize = HMAC_RES_SIZE;
unsigned char hmacRes[HMAC_RES_SIZE];
- unsigned long timestamp = time(NULL)/30;
+ unsigned long timestamp = time(nullptr)/30;
unsigned char challenge[8];
for (int i = 8; i--;timestamp >>= 8)
diff --git a/src/server/authserver/Authentication/TOTP.h b/src/server/authserver/Authentication/TOTP.h
index 94a3383e831..7137bb0e662 100644
--- a/src/server/authserver/Authentication/TOTP.h
+++ b/src/server/authserver/Authentication/TOTP.h
@@ -23,7 +23,7 @@
namespace TOTP
{
- unsigned int GenerateToken(const char* b32key);
+ unsigned int GenerateToken(char const* b32key);
}
#endif
diff --git a/src/server/authserver/Main.cpp b/src/server/authserver/Main.cpp
index 6e67a950343..072810867b1 100644
--- a/src/server/authserver/Main.cpp
+++ b/src/server/authserver/Main.cpp
@@ -24,22 +24,24 @@
* authentication server
*/
+#include "AppenderDB.h"
#include "AuthSocketMgr.h"
-#include "Common.h"
+#include "Banner.h"
#include "Config.h"
#include "DatabaseEnv.h"
#include "DatabaseLoader.h"
-#include "Log.h"
-#include "AppenderDB.h"
+#include "GitRevision.h"
+#include "MySQLThreading.h"
#include "ProcessPriority.h"
#include "RealmList.h"
-#include "GitRevision.h"
#include "Util.h"
-#include <iostream>
-#include <boost/filesystem/path.hpp>
+#include <boost/asio/signal_set.hpp>
#include <boost/program_options.hpp>
-#include <openssl/opensslv.h>
+#include <boost/filesystem/operations.hpp>
#include <openssl/crypto.h>
+#include <openssl/opensslv.h>
+#include <iostream>
+#include <csignal>
using boost::asio::ip::tcp;
using namespace boost::program_options;
@@ -104,11 +106,18 @@ int main(int argc, char** argv)
sLog->RegisterAppender<AppenderDB>();
sLog->Initialize(nullptr);
- TC_LOG_INFO("server.authserver", "%s (authserver)", GitRevision::GetFullVersion());
- TC_LOG_INFO("server.authserver", "<Ctrl-C> to stop.\n");
- TC_LOG_INFO("server.authserver", "Using configuration file %s.", sConfigMgr->GetFilename().c_str());
- TC_LOG_INFO("server.authserver", "Using SSL version: %s (library: %s)", OPENSSL_VERSION_TEXT, SSLeay_version(SSLEAY_VERSION));
- TC_LOG_INFO("server.authserver", "Using Boost version: %i.%i.%i", BOOST_VERSION / 100000, BOOST_VERSION / 100 % 1000, BOOST_VERSION % 100);
+ Trinity::Banner::Show("authserver",
+ [](char const* text)
+ {
+ TC_LOG_INFO("server.authserver", "%s", text);
+ },
+ []()
+ {
+ TC_LOG_INFO("server.authserver", "Using configuration file %s.", sConfigMgr->GetFilename().c_str());
+ TC_LOG_INFO("server.authserver", "Using SSL version: %s (library: %s)", OPENSSL_VERSION_TEXT, SSLeay_version(SSLEAY_VERSION));
+ TC_LOG_INFO("server.authserver", "Using Boost version: %i.%i.%i", BOOST_VERSION / 100000, BOOST_VERSION / 100 % 1000, BOOST_VERSION % 100);
+ }
+ );
// authserver PID file creation
std::string pidFile = sConfigMgr->GetStringDefault("PidFile", "");
@@ -168,7 +177,7 @@ int main(int argc, char** argv)
signals.async_wait(std::bind(&SignalHandler, std::weak_ptr<boost::asio::io_service>(ioService), std::placeholders::_1, std::placeholders::_2));
// Set process priority according to configuration settings
- SetProcessPriority("server.authserver");
+ SetProcessPriority("server.authserver", sConfigMgr->GetIntDefault(CONFIG_PROCESSOR_AFFINITY, 0), sConfigMgr->GetBoolDefault(CONFIG_HIGH_PRIORITY, false));
// Enabled a timed callback for handling the database keep alive ping
int32 dbPingInterval = sConfigMgr->GetIntDefault("MaxPingTime", 30);
diff --git a/src/server/authserver/PrecompiledHeaders/authPCH.cpp b/src/server/authserver/PrecompiledHeaders/authPCH.cpp
index eed50cb2c0b..76ee97ee0e7 100644
--- a/src/server/authserver/PrecompiledHeaders/authPCH.cpp
+++ b/src/server/authserver/PrecompiledHeaders/authPCH.cpp
@@ -1 +1,18 @@
+/*
+ * Copyright (C) 2008-2017 TrinityCore <http://www.trinitycore.org/>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
#include "authPCH.h"
diff --git a/src/server/authserver/PrecompiledHeaders/authPCH.h b/src/server/authserver/PrecompiledHeaders/authPCH.h
index ef757a656d5..26a070fba64 100644
--- a/src/server/authserver/PrecompiledHeaders/authPCH.h
+++ b/src/server/authserver/PrecompiledHeaders/authPCH.h
@@ -1,3 +1,20 @@
+/*
+ * Copyright (C) 2008-2017 TrinityCore <http://www.trinitycore.org/>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
#include "Common.h"
#include "Configuration/Config.h"
#include "Database/DatabaseEnv.h"
diff --git a/src/server/authserver/Server/AuthSession.cpp b/src/server/authserver/Server/AuthSession.cpp
index dfd77c39cb5..8e6ec882636 100644
--- a/src/server/authserver/Server/AuthSession.cpp
+++ b/src/server/authserver/Server/AuthSession.cpp
@@ -17,16 +17,17 @@
*/
#include "AuthSession.h"
-#include "Log.h"
#include "AuthCodes.h"
-#include "Database/DatabaseEnv.h"
-#include "QueryCallback.h"
+#include "Config.h"
+#include "Errors.h"
+#include "Log.h"
+#include "DatabaseEnv.h"
+#include "RealmList.h"
#include "SHA1.h"
#include "TOTP.h"
-#include "openssl/crypto.h"
-#include "Configuration/Config.h"
-#include "RealmList.h"
+#include "Util.h"
#include <boost/lexical_cast.hpp>
+#include <openssl/crypto.h>
using boost::asio::ip::tcp;
@@ -285,7 +286,7 @@ bool AuthSession::HandleLogonChallenge()
if (challenge->size - (sizeof(sAuthLogonChallenge_C) - AUTH_LOGON_CHALLENGE_INITIAL_SIZE - 1) != challenge->I_len)
return false;
- std::string login((const char*)challenge->I, challenge->I_len);
+ std::string login((char const*)challenge->I, challenge->I_len);
TC_LOG_DEBUG("server.authserver", "[AuthChallenge] '%s'", login.c_str());
_build = challenge->build;
@@ -481,7 +482,7 @@ bool AuthSession::HandleLogonProof()
return false;
SHA1Hash sha;
- sha.UpdateBigNumbers(&A, &B, NULL);
+ sha.UpdateBigNumbers(&A, &B, nullptr);
sha.Finalize();
BigNumber u;
u.SetBinary(sha.GetDigest(), 20);
@@ -517,11 +518,11 @@ bool AuthSession::HandleLogonProof()
uint8 hash[20];
sha.Initialize();
- sha.UpdateBigNumbers(&N, NULL);
+ sha.UpdateBigNumbers(&N, nullptr);
sha.Finalize();
memcpy(hash, sha.GetDigest(), 20);
sha.Initialize();
- sha.UpdateBigNumbers(&g, NULL);
+ sha.UpdateBigNumbers(&g, nullptr);
sha.Finalize();
for (int i = 0; i < 20; ++i)
@@ -537,9 +538,9 @@ bool AuthSession::HandleLogonProof()
memcpy(t4, sha.GetDigest(), SHA_DIGEST_LENGTH);
sha.Initialize();
- sha.UpdateBigNumbers(&t3, NULL);
+ sha.UpdateBigNumbers(&t3, nullptr);
sha.UpdateData(t4, SHA_DIGEST_LENGTH);
- sha.UpdateBigNumbers(&s, &A, &B, &K, NULL);
+ sha.UpdateBigNumbers(&s, &A, &B, &K, nullptr);
sha.Finalize();
BigNumber M;
M.SetBinary(sha.GetDigest(), sha.GetLength());
@@ -583,7 +584,7 @@ bool AuthSession::HandleLogonProof()
// Finish SRP6 and send the final result to the client
sha.Initialize();
- sha.UpdateBigNumbers(&A, &M, &K, NULL);
+ sha.UpdateBigNumbers(&A, &M, &K, nullptr);
sha.Finalize();
ByteBuffer packet;
@@ -687,7 +688,7 @@ bool AuthSession::HandleReconnectChallenge()
if (challenge->size - (sizeof(sAuthLogonChallenge_C) - AUTH_LOGON_CHALLENGE_INITIAL_SIZE - 1) != challenge->I_len)
return false;
- std::string login((const char*)challenge->I, challenge->I_len);
+ std::string login((char const*)challenge->I, challenge->I_len);
TC_LOG_DEBUG("server.authserver", "[ReconnectChallenge] '%s'", login.c_str());
_build = challenge->build;
@@ -754,7 +755,7 @@ bool AuthSession::HandleReconnectProof()
SHA1Hash sha;
sha.Initialize();
sha.UpdateData(_accountInfo.Login);
- sha.UpdateBigNumbers(&t1, &_reconnectProof, &K, NULL);
+ sha.UpdateBigNumbers(&t1, &_reconnectProof, &K, nullptr);
sha.Finalize();
if (!memcmp(sha.GetDigest(), reconnectProof->R2, SHA_DIGEST_LENGTH))
@@ -805,7 +806,7 @@ void AuthSession::RealmListCallback(PreparedQueryResult result)
size_t RealmListSize = 0;
for (RealmList::RealmMap::value_type const& i : sRealmList->GetRealms())
{
- const Realm &realm = i.second;
+ Realm const& realm = i.second;
// don't work with realms which not compatible with the client
bool okBuild = ((_expversion & POST_BC_EXP_FLAG) && realm.Build == _build) || ((_expversion & PRE_BC_EXP_FLAG) && !AuthHelper::IsPreBCAcceptedClientBuild(realm.Build));