aboutsummaryrefslogtreecommitdiff
path: root/src/server/bnetserver/Main.cpp
diff options
context:
space:
mode:
authorLopfest <lopfest@gmail.com>2016-02-20 23:59:56 +0100
committerLopfest <lopfest@gmail.com>2016-02-20 23:59:56 +0100
commitfacdc62b433787326673a4db05aab76d75e1283f (patch)
treef76f4e3467e3fe909da8b4e5bc5962712642e493 /src/server/bnetserver/Main.cpp
parentd11eb335c996b398f4f8bdb10558dfba9af637f4 (diff)
parent716c952cb9f7bc0f75308bb4a716cdfe7de17281 (diff)
Merge remote-tracking branch 'upstream/6.x' into HEAD
Diffstat (limited to 'src/server/bnetserver/Main.cpp')
-rw-r--r--src/server/bnetserver/Main.cpp30
1 files changed, 26 insertions, 4 deletions
diff --git a/src/server/bnetserver/Main.cpp b/src/server/bnetserver/Main.cpp
index 3d1481fae9e..740a0efa438 100644
--- a/src/server/bnetserver/Main.cpp
+++ b/src/server/bnetserver/Main.cpp
@@ -71,13 +71,16 @@ void ServiceStatusWatcher(boost::system::error_code const& error);
bool StartDB();
void StopDB();
-void SignalHandler(const boost::system::error_code& error, int signalNumber);
-void KeepDatabaseAliveHandler(const boost::system::error_code& error);
+void SignalHandler(boost::system::error_code const& error, int signalNumber);
+void KeepDatabaseAliveHandler(boost::system::error_code const& error);
+void BanExpiryHandler(boost::system::error_code const& error);
variables_map GetConsoleArguments(int argc, char** argv, std::string& configFile, std::string& configService);
static boost::asio::io_service* _ioService;
static boost::asio::deadline_timer* _dbPingTimer;
static uint32 _dbPingInterval;
+static boost::asio::deadline_timer* _banExpiryCheckTimer;
+static uint32 _banExpiryCheckInterval;
LoginDatabaseWorkerPool LoginDatabase;
int main(int argc, char** argv)
@@ -180,6 +183,11 @@ int main(int argc, char** argv)
_dbPingTimer->expires_from_now(boost::posix_time::minutes(_dbPingInterval));
_dbPingTimer->async_wait(KeepDatabaseAliveHandler);
+ _banExpiryCheckInterval = sConfigMgr->GetIntDefault("BanExpiryCheckInterval", 60);
+ _banExpiryCheckTimer = new boost::asio::deadline_timer(*_ioService);
+ _banExpiryCheckTimer->expires_from_now(boost::posix_time::seconds(_banExpiryCheckInterval));
+ _banExpiryCheckTimer->async_wait(BanExpiryHandler);
+
sComponentMgr->Load();
sModuleMgr->Load();
@@ -195,6 +203,7 @@ int main(int argc, char** argv)
// Start the io service worker loop
_ioService->run();
+ _banExpiryCheckTimer->cancel();
_dbPingTimer->cancel();
sSessionMgr.StopNetwork();
@@ -210,6 +219,7 @@ int main(int argc, char** argv)
signals.cancel();
+ delete _banExpiryCheckTimer;
delete _dbPingTimer;
delete _ioService;
return 0;
@@ -240,13 +250,13 @@ void StopDB()
MySQL::Library_End();
}
-void SignalHandler(const boost::system::error_code& error, int /*signalNumber*/)
+void SignalHandler(boost::system::error_code const& error, int /*signalNumber*/)
{
if (!error)
_ioService->stop();
}
-void KeepDatabaseAliveHandler(const boost::system::error_code& error)
+void KeepDatabaseAliveHandler(boost::system::error_code const& error)
{
if (!error)
{
@@ -258,6 +268,18 @@ void KeepDatabaseAliveHandler(const boost::system::error_code& error)
}
}
+void BanExpiryHandler(boost::system::error_code const& error)
+{
+ if (!error)
+ {
+ LoginDatabase.Execute(LoginDatabase.GetPreparedStatement(LOGIN_DEL_EXPIRED_IP_BANS));
+ LoginDatabase.Execute(LoginDatabase.GetPreparedStatement(LOGIN_UPD_EXPIRED_ACCOUNT_BANS));
+
+ _banExpiryCheckTimer->expires_from_now(boost::posix_time::seconds(_banExpiryCheckInterval));
+ _banExpiryCheckTimer->async_wait(BanExpiryHandler);
+ }
+}
+
#if PLATFORM == PLATFORM_WINDOWS
void ServiceStatusWatcher(boost::system::error_code const& error)
{