Skip to content

Commit

Permalink
final approach of MTH 5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Pryan committed Oct 16, 2019
1 parent fe22c11 commit 2c39047
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 16 deletions.
4 changes: 3 additions & 1 deletion include/ZeusBaseClass.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class User {
class LocalUser : public User {
public:
LocalUser() : User(config->Getvalue("serverName")), mLang(config->Getvalue("language")) {};
virtual ~LocalUser() { };
virtual ~LocalUser() { threads.clear(); };
static LocalUser *FindLocalUser(std::string nick);
void Parse(std::string message);
void CheckPing();
Expand Down Expand Up @@ -124,6 +124,8 @@ class LocalUser : public User {
std::string PassWord;
std::string mLang;
std::mutex mtx;

std::vector<std::thread> threads;
};

class PlainUser : public LocalUser, public std::enable_shared_from_this<PlainUser> {
Expand Down
4 changes: 2 additions & 2 deletions include/sqlite.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,9 @@ namespace sqlite
this->_filename = filename;
int rc;
if (readonly == true)
rc = sqlite3_open_v2(filename.c_str(), &this->_db, SQLITE_OPEN_READONLY | SQLITE_OPEN_FULLMUTEX, NULL);
rc = sqlite3_open_v2(filename.c_str(), &this->_db, SQLITE_OPEN_READONLY, NULL);
else
rc = sqlite3_open_v2(filename.c_str(), &this->_db, SQLITE_OPEN_READWRITE | SQLITE_OPEN_FULLMUTEX, NULL);
rc = sqlite3_open_v2(filename.c_str(), &this->_db, SQLITE_OPEN_READWRITE, NULL);
if(rc != SQLITE_OK)
{
exception e("Could not open '" + filename + "'");
Expand Down
7 changes: 4 additions & 3 deletions src/PlainUser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,10 @@ void PlainUser::handleRead(const boost::system::error_code& error, std::size_t b

message.erase(boost::remove_if(message, boost::is_any_of("\r\n")), message.end());

std::thread t(boost::bind(&PlainUser::Parse, shared_from_this(), message));
t.join();

std::thread t = std::thread(boost::bind(&PlainUser::Parse, shared_from_this(), message));
t.detach();
threads.push_back(std::move(t));

read();
} else
Exit();
Expand Down
5 changes: 3 additions & 2 deletions src/SSLUser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,9 @@ void LocalSSLUser::handleRead(const boost::system::error_code& error, std::size_

message.erase(boost::remove_if(message, boost::is_any_of("\r\n")), message.end());

std::thread t(boost::bind(&LocalSSLUser::Parse, shared_from_this(), message));
t.join();
std::thread t = std::thread(boost::bind(&LocalSSLUser::Parse, shared_from_this(), message));
t.detach();
threads.push_back(std::move(t));

read();
} else
Expand Down
5 changes: 3 additions & 2 deletions src/WebUser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,9 @@ void LocalWebUser::handleRead(const boost::system::error_code &error, std::size_

message.erase(boost::remove_if(message, boost::is_any_of("\r\n")), message.end());

std::thread t(boost::bind(&LocalWebUser::Parse, shared_from_this(), message));
t.join();
std::thread t = std::thread(boost::bind(&LocalWebUser::Parse, shared_from_this(), message));
t.detach();
threads.push_back(std::move(t));

read();
} else
Expand Down
12 changes: 6 additions & 6 deletions src/ZeusBaseClass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,15 +225,15 @@ void ClientServer::handleAccept(const std::shared_ptr<PlainUser> newclient, cons
if (stoi(config->Getvalue("maxUsers")) <= Mainframe::instance()->countusers()) {
newclient->SendAsServer("465 ZeusiRCd :" + Utils::make_string("", "The server has reached maximum number of connections."));
newclient->Close();
} else if (Server::CheckClone(newclient->ip()) == true) {
newclient->SendAsServer("465 ZeusiRCd :" + Utils::make_string("", "You have reached the maximum number of clones."));
newclient->Close();
// } else if (Server::CheckClone(newclient->ip()) == true) {
// newclient->SendAsServer("465 ZeusiRCd :" + Utils::make_string("", "You have reached the maximum number of clones."));
// newclient->Close();
} else if (Server::CheckDNSBL(newclient->ip()) == true) {
newclient->SendAsServer("465 ZeusiRCd :" + Utils::make_string("", "Your IP is in our DNSBL lists."));
newclient->Close();
} else if (Server::CheckThrottle(newclient->ip()) == true) {
newclient->SendAsServer("465 ZeusiRCd :" + Utils::make_string("", "You connect too fast, wait 30 seconds to try connect again."));
newclient->Close();
// } else if (Server::CheckThrottle(newclient->ip()) == true) {
// newclient->SendAsServer("465 ZeusiRCd :" + Utils::make_string("", "You connect too fast, wait 30 seconds to try connect again."));
// newclient->Close();
} else if (OperServ::IsGlined(newclient->ip()) == true) {
newclient->SendAsServer("465 ZeusiRCd :" + Utils::make_string("", "You are G-Lined. Reason: %s", OperServ::ReasonGlined(newclient->ip()).c_str()));
newclient->Close();
Expand Down

0 comments on commit 2c39047

Please sign in to comment.