mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-20 17:27:36 +01:00
Damn you VS default settings..
This commit is contained in:
@@ -67,28 +67,28 @@ using boost::asio::ip::tcp;
|
||||
|
||||
void SignalHandler(const boost::system::error_code& error, int signalNumber)
|
||||
{
|
||||
TC_LOG_ERROR("server.authserver", "SIGNAL HANDLER WORKING");
|
||||
if (!error)
|
||||
{
|
||||
switch (signalNumber)
|
||||
{
|
||||
case SIGINT:
|
||||
case SIGTERM:
|
||||
_ioService.stop();
|
||||
break;
|
||||
}
|
||||
}
|
||||
TC_LOG_ERROR("server.authserver", "SIGNAL HANDLER WORKING");
|
||||
if (!error)
|
||||
{
|
||||
switch (signalNumber)
|
||||
{
|
||||
case SIGINT:
|
||||
case SIGTERM:
|
||||
_ioService.stop();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void KeepDatabaseAliveHandler(const boost::system::error_code& error)
|
||||
{
|
||||
if (!error)
|
||||
{
|
||||
TC_LOG_INFO("server.authserver", "Ping MySQL to keep connection alive");
|
||||
LoginDatabase.KeepAlive();
|
||||
if (!error)
|
||||
{
|
||||
TC_LOG_INFO("server.authserver", "Ping MySQL to keep connection alive");
|
||||
LoginDatabase.KeepAlive();
|
||||
|
||||
_dbPingTimer.expires_from_now(boost::posix_time::minutes(_dbPingInterval));
|
||||
}
|
||||
_dbPingTimer.expires_from_now(boost::posix_time::minutes(_dbPingInterval));
|
||||
}
|
||||
}
|
||||
|
||||
/// Print out the usage string for this program on the console.
|
||||
@@ -170,22 +170,22 @@ int main(int argc, char** argv)
|
||||
|
||||
std::string bindIp = sConfigMgr->GetStringDefault("BindIP", "0.0.0.0");
|
||||
|
||||
AuthServer authServer(_ioService, bindIp, port);
|
||||
AuthServer authServer(_ioService, bindIp, port);
|
||||
|
||||
// Set signal handlers
|
||||
boost::asio::signal_set signals(_ioService, SIGINT, SIGTERM);
|
||||
signals.async_wait(SignalHandler);
|
||||
// Set signal handlers
|
||||
boost::asio::signal_set signals(_ioService, SIGINT, SIGTERM);
|
||||
signals.async_wait(SignalHandler);
|
||||
|
||||
SetProcessPriority();
|
||||
SetProcessPriority();
|
||||
|
||||
|
||||
_dbPingInterval = sConfigMgr->GetIntDefault("MaxPingTime", 30);
|
||||
_dbPingInterval = sConfigMgr->GetIntDefault("MaxPingTime", 30);
|
||||
|
||||
_dbPingTimer.expires_from_now(boost::posix_time::seconds(_dbPingInterval));
|
||||
_dbPingTimer.async_wait(KeepDatabaseAliveHandler);
|
||||
_dbPingTimer.expires_from_now(boost::posix_time::seconds(_dbPingInterval));
|
||||
_dbPingTimer.async_wait(KeepDatabaseAliveHandler);
|
||||
|
||||
// Start the io service
|
||||
_ioService.run();
|
||||
// Start the io service
|
||||
_ioService.run();
|
||||
|
||||
// Close the Database Pool and library
|
||||
StopDB();
|
||||
@@ -244,69 +244,69 @@ void SetProcessPriority()
|
||||
{
|
||||
#if defined(_WIN32) || defined(__linux__)
|
||||
|
||||
///- Handle affinity for multiple processors and process priority
|
||||
uint32 affinity = sConfigMgr->GetIntDefault("UseProcessors", 0);
|
||||
bool highPriority = sConfigMgr->GetBoolDefault("ProcessPriority", false);
|
||||
///- Handle affinity for multiple processors and process priority
|
||||
uint32 affinity = sConfigMgr->GetIntDefault("UseProcessors", 0);
|
||||
bool highPriority = sConfigMgr->GetBoolDefault("ProcessPriority", false);
|
||||
|
||||
#ifdef _WIN32 // Windows
|
||||
|
||||
HANDLE hProcess = GetCurrentProcess();
|
||||
if (affinity > 0)
|
||||
{
|
||||
ULONG_PTR appAff;
|
||||
ULONG_PTR sysAff;
|
||||
HANDLE hProcess = GetCurrentProcess();
|
||||
if (affinity > 0)
|
||||
{
|
||||
ULONG_PTR appAff;
|
||||
ULONG_PTR sysAff;
|
||||
|
||||
if (GetProcessAffinityMask(hProcess, &appAff, &sysAff))
|
||||
{
|
||||
// remove non accessible processors
|
||||
ULONG_PTR currentAffinity = affinity & appAff;
|
||||
if (GetProcessAffinityMask(hProcess, &appAff, &sysAff))
|
||||
{
|
||||
// remove non accessible processors
|
||||
ULONG_PTR currentAffinity = affinity & appAff;
|
||||
|
||||
if (!currentAffinity)
|
||||
TC_LOG_ERROR("server.authserver", "Processors marked in UseProcessors bitmask (hex) %x are not accessible for the authserver. Accessible processors bitmask (hex): %x", affinity, appAff);
|
||||
else if (SetProcessAffinityMask(hProcess, currentAffinity))
|
||||
TC_LOG_INFO("server.authserver", "Using processors (bitmask, hex): %x", currentAffinity);
|
||||
else
|
||||
TC_LOG_ERROR("server.authserver", "Can't set used processors (hex): %x", currentAffinity);
|
||||
}
|
||||
}
|
||||
if (!currentAffinity)
|
||||
TC_LOG_ERROR("server.authserver", "Processors marked in UseProcessors bitmask (hex) %x are not accessible for the authserver. Accessible processors bitmask (hex): %x", affinity, appAff);
|
||||
else if (SetProcessAffinityMask(hProcess, currentAffinity))
|
||||
TC_LOG_INFO("server.authserver", "Using processors (bitmask, hex): %x", currentAffinity);
|
||||
else
|
||||
TC_LOG_ERROR("server.authserver", "Can't set used processors (hex): %x", currentAffinity);
|
||||
}
|
||||
}
|
||||
|
||||
if (highPriority)
|
||||
{
|
||||
if (SetPriorityClass(hProcess, HIGH_PRIORITY_CLASS))
|
||||
TC_LOG_INFO("server.authserver", "authserver process priority class set to HIGH");
|
||||
else
|
||||
TC_LOG_ERROR("server.authserver", "Can't set authserver process priority class.");
|
||||
}
|
||||
if (highPriority)
|
||||
{
|
||||
if (SetPriorityClass(hProcess, HIGH_PRIORITY_CLASS))
|
||||
TC_LOG_INFO("server.authserver", "authserver process priority class set to HIGH");
|
||||
else
|
||||
TC_LOG_ERROR("server.authserver", "Can't set authserver process priority class.");
|
||||
}
|
||||
|
||||
#else // Linux
|
||||
|
||||
if (affinity > 0)
|
||||
{
|
||||
cpu_set_t mask;
|
||||
CPU_ZERO(&mask);
|
||||
if (affinity > 0)
|
||||
{
|
||||
cpu_set_t mask;
|
||||
CPU_ZERO(&mask);
|
||||
|
||||
for (unsigned int i = 0; i < sizeof(affinity) * 8; ++i)
|
||||
if (affinity & (1 << i))
|
||||
CPU_SET(i, &mask);
|
||||
for (unsigned int i = 0; i < sizeof(affinity) * 8; ++i)
|
||||
if (affinity & (1 << i))
|
||||
CPU_SET(i, &mask);
|
||||
|
||||
if (sched_setaffinity(0, sizeof(mask), &mask))
|
||||
TC_LOG_ERROR("server.authserver", "Can't set used processors (hex): %x, error: %s", affinity, strerror(errno));
|
||||
else
|
||||
{
|
||||
CPU_ZERO(&mask);
|
||||
sched_getaffinity(0, sizeof(mask), &mask);
|
||||
TC_LOG_INFO("server.authserver", "Using processors (bitmask, hex): %lx", *(__cpu_mask*)(&mask));
|
||||
}
|
||||
}
|
||||
if (sched_setaffinity(0, sizeof(mask), &mask))
|
||||
TC_LOG_ERROR("server.authserver", "Can't set used processors (hex): %x, error: %s", affinity, strerror(errno));
|
||||
else
|
||||
{
|
||||
CPU_ZERO(&mask);
|
||||
sched_getaffinity(0, sizeof(mask), &mask);
|
||||
TC_LOG_INFO("server.authserver", "Using processors (bitmask, hex): %lx", *(__cpu_mask*)(&mask));
|
||||
}
|
||||
}
|
||||
|
||||
if (highPriority)
|
||||
{
|
||||
if (setpriority(PRIO_PROCESS, 0, PROCESS_HIGH_PRIORITY))
|
||||
TC_LOG_ERROR("server.authserver", "Can't set authserver process priority class, error: %s", strerror(errno));
|
||||
else
|
||||
TC_LOG_INFO("server.authserver", "authserver process priority class set to %i", getpriority(PRIO_PROCESS, 0));
|
||||
}
|
||||
if (highPriority)
|
||||
{
|
||||
if (setpriority(PRIO_PROCESS, 0, PROCESS_HIGH_PRIORITY))
|
||||
TC_LOG_ERROR("server.authserver", "Can't set authserver process priority class, error: %s", strerror(errno));
|
||||
else
|
||||
TC_LOG_INFO("server.authserver", "authserver process priority class set to %i", getpriority(PRIO_PROCESS, 0));
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,15 +26,15 @@
|
||||
|
||||
enum RealmFlags
|
||||
{
|
||||
REALM_FLAG_NONE = 0x00,
|
||||
REALM_FLAG_INVALID = 0x01,
|
||||
REALM_FLAG_OFFLINE = 0x02,
|
||||
REALM_FLAG_SPECIFYBUILD = 0x04,
|
||||
REALM_FLAG_UNK1 = 0x08,
|
||||
REALM_FLAG_UNK2 = 0x10,
|
||||
REALM_FLAG_RECOMMENDED = 0x20,
|
||||
REALM_FLAG_NEW = 0x40,
|
||||
REALM_FLAG_FULL = 0x80
|
||||
REALM_FLAG_NONE = 0x00,
|
||||
REALM_FLAG_INVALID = 0x01,
|
||||
REALM_FLAG_OFFLINE = 0x02,
|
||||
REALM_FLAG_SPECIFYBUILD = 0x04,
|
||||
REALM_FLAG_UNK1 = 0x08,
|
||||
REALM_FLAG_UNK2 = 0x10,
|
||||
REALM_FLAG_RECOMMENDED = 0x20,
|
||||
REALM_FLAG_NEW = 0x40,
|
||||
REALM_FLAG_FULL = 0x80
|
||||
};
|
||||
|
||||
// Storage object for a realm
|
||||
@@ -73,7 +73,7 @@ public:
|
||||
uint32 size() const { return m_realms.size(); }
|
||||
|
||||
private:
|
||||
void UpdateRealms(bool init=false);
|
||||
void UpdateRealms(bool init = false);
|
||||
void UpdateRealm(uint32 id, const std::string& name, ACE_INET_Addr const& address, ACE_INET_Addr const& localAddr, ACE_INET_Addr const& localSubmask, uint8 icon, RealmFlags flag, uint8 timezone, AccountTypes allowedSecurityLevel, float popu, uint32 build);
|
||||
|
||||
RealmMap m_realms;
|
||||
|
||||
@@ -25,15 +25,15 @@ using boost::asio::ip::tcp;
|
||||
|
||||
void AuthServer::AsyncAccept()
|
||||
{
|
||||
_acceptor.async_accept(_socket, [this](boost::system::error_code error)
|
||||
{
|
||||
if (!error)
|
||||
{
|
||||
std::make_shared<AuthSession>(std::move(_socket))->Start();
|
||||
}
|
||||
_acceptor.async_accept(_socket, [this](boost::system::error_code error)
|
||||
{
|
||||
if (!error)
|
||||
{
|
||||
std::make_shared<AuthSession>(std::move(_socket))->Start();
|
||||
}
|
||||
|
||||
AsyncAccept();
|
||||
});
|
||||
AsyncAccept();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -25,20 +25,20 @@ using boost::asio::ip::tcp;
|
||||
class AuthServer
|
||||
{
|
||||
public:
|
||||
AuthServer(boost::asio::io_service& ioService, std::string bindIp, int port) : _socket(ioService), _acceptor(ioService, tcp::endpoint(tcp::v4(), port))
|
||||
{
|
||||
tcp::endpoint endpoint(boost::asio::ip::address::from_string(bindIp), port);
|
||||
AuthServer(boost::asio::io_service& ioService, std::string bindIp, int port) : _socket(ioService), _acceptor(ioService, tcp::endpoint(tcp::v4(), port))
|
||||
{
|
||||
tcp::endpoint endpoint(boost::asio::ip::address::from_string(bindIp), port);
|
||||
|
||||
_acceptor = tcp::acceptor(ioService, endpoint);
|
||||
_acceptor = tcp::acceptor(ioService, endpoint);
|
||||
|
||||
AsyncAccept();
|
||||
};
|
||||
AsyncAccept();
|
||||
};
|
||||
|
||||
private:
|
||||
void AsyncAccept();
|
||||
void AsyncAccept();
|
||||
|
||||
tcp::acceptor _acceptor;
|
||||
tcp::socket _socket;
|
||||
tcp::acceptor _acceptor;
|
||||
tcp::socket _socket;
|
||||
};
|
||||
|
||||
#endif /* __AUTHSERVER_H__ */
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -34,52 +34,52 @@ const size_t bufferSize = 4096;
|
||||
class AuthSession : public std::enable_shared_from_this < AuthSession >
|
||||
{
|
||||
public:
|
||||
AuthSession(tcp::socket socket) : _socket(std::move(socket))
|
||||
{
|
||||
N.SetHexStr("894B645E89E1535BBDAD5B8B290650530801B18EBFBF5E8FAB3C82872A3E9BB7");
|
||||
g.SetDword(7);
|
||||
}
|
||||
AuthSession(tcp::socket socket) : _socket(std::move(socket))
|
||||
{
|
||||
N.SetHexStr("894B645E89E1535BBDAD5B8B290650530801B18EBFBF5E8FAB3C82872A3E9BB7");
|
||||
g.SetDword(7);
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
AsyncReadHeader();
|
||||
}
|
||||
void Start()
|
||||
{
|
||||
AsyncReadHeader();
|
||||
}
|
||||
|
||||
bool _HandleLogonChallenge();
|
||||
bool _HandleLogonProof();
|
||||
bool _HandleReconnectChallenge();
|
||||
bool _HandleReconnectProof();
|
||||
bool _HandleRealmList();
|
||||
bool _HandleLogonChallenge();
|
||||
bool _HandleLogonProof();
|
||||
bool _HandleReconnectChallenge();
|
||||
bool _HandleReconnectProof();
|
||||
bool _HandleRealmList();
|
||||
|
||||
const std::string GetRemoteIpAddress() const { return _socket.remote_endpoint().address().to_string(); };
|
||||
unsigned short GetRemotePort() const { return _socket.remote_endpoint().port(); }
|
||||
const std::string GetRemoteIpAddress() const { return _socket.remote_endpoint().address().to_string(); };
|
||||
unsigned short GetRemotePort() const { return _socket.remote_endpoint().port(); }
|
||||
|
||||
private:
|
||||
void AsyncReadHeader();
|
||||
void AsyncReadData(bool (AuthSession::*handler)(), size_t dataSize, size_t bufferOffset);
|
||||
void AsyncWrite(size_t length);
|
||||
void AsyncReadHeader();
|
||||
void AsyncReadData(bool (AuthSession::*handler)(), size_t dataSize, size_t bufferOffset);
|
||||
void AsyncWrite(size_t length);
|
||||
|
||||
|
||||
void SetVSFields(const std::string& rI);
|
||||
void SetVSFields(const std::string& rI);
|
||||
|
||||
BigNumber N, s, g, v;
|
||||
BigNumber b, B;
|
||||
BigNumber K;
|
||||
BigNumber _reconnectProof;
|
||||
BigNumber N, s, g, v;
|
||||
BigNumber b, B;
|
||||
BigNumber K;
|
||||
BigNumber _reconnectProof;
|
||||
|
||||
tcp::socket _socket;
|
||||
char _readBuffer[BUFFER_SIZE];
|
||||
char _writeBuffer[BUFFER_SIZE];
|
||||
tcp::socket _socket;
|
||||
char _readBuffer[BUFFER_SIZE];
|
||||
char _writeBuffer[BUFFER_SIZE];
|
||||
|
||||
bool _isAuthenticated;
|
||||
std::string _tokenKey;
|
||||
std::string _login;
|
||||
std::string _localizationName;
|
||||
std::string _os;
|
||||
uint16 _build;
|
||||
uint8 _expversion;
|
||||
bool _isAuthenticated;
|
||||
std::string _tokenKey;
|
||||
std::string _login;
|
||||
std::string _localizationName;
|
||||
std::string _os;
|
||||
uint16 _build;
|
||||
uint8 _expversion;
|
||||
|
||||
AccountTypes _accountSecurityLevel;
|
||||
AccountTypes _accountSecurityLevel;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user