New build.

This commit is contained in:
barant committed 2020-04-13 09:40:58 -07:00
1 parent a5a51f8aae
commit b4ab5fb86a
835 files changed
+26499 -3119

No files matched your search

+10 -7
View File
@@ -23,26 +23,28 @@ namespace core {
}
void TCPServer::onDataReceived(std::string data) {
coreutils::Log(coreutils::LOG_DEBUG_2) << "entering TCPServer::onDataReceived socket " << getDescriptor() << ".";
lock.lock();
TCPSession *session = accept();
if(session) sessions.push_back(session);
if(session)
sessions.push_back(session);
lock.unlock();
coreutils::Log(coreutils::LOG_DEBUG_2) << "Leaving TCPServer::onDataReceived socket " << getDescriptor() << ".";
}
TCPSession * TCPServer::accept() {
TCPSession * TCPServer::accept() {
TCPSession *session = getSocketAccept(ePoll);
session->setDescriptor(::accept(getDescriptor(), (struct sockaddr *)&session->ipAddress.addr, &session->ipAddress.addressLength));
session->setDescriptor(::accept(getDescriptor(), (struct sockaddr *)&session->ipAddress.addr, &session->ipAddress.addressLength));
// if(blackList && blackList->contains(session->ipAddress.getClientAddress())) {
// session->shutdown();
// Log(LOG_WARN) << "Client at IP address " << session->ipAddress.getClientAddress() << " is blacklisted and was denied a connection.";
// return NULL;
// }
//
// if(whiteList && !whiteList->contains(session->ipAddress.getClientAddress())) {
// session->shutdown();
// Log(LOG_WARN) << "Client at IP address " << session->ipAddress.getClientAddress() << " is not authorized and was denied a connection.";
// return NULL;
// }
//
coreutils::Log(coreutils::LOG_DEBUG_2) << "Session started on socket " << session->getDescriptor() << ".";
return session;
}
@@ -65,7 +67,7 @@ namespace core {
void TCPServer::output(TCPSession *session) {
std::stringstream out;
out << "|" << session->ipAddress.getClientAddressAndPort();
session->send(out.str());
session->send();
}
int TCPServer::processCommand(std::string command, TCPSession *session, std::stringstream &data) {
@@ -75,6 +77,7 @@ namespace core {
sessionx->output(data);
data << "|" << std::endl;
}
return 1;
}
}