TLS work. Not done.

This commit is contained in:
barant committed 2019-09-20 20:25:45 -07:00
1 parent e6c1e9db0d
commit 43a24b900a
11 files changed
+92 -93

No files matched your search

+17 -17
View File
@@ -11,16 +11,16 @@ namespace core {
int yes = 1;
setsockopt(getDescriptor(), SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int));
if(bind(getDescriptor(), address.getPointer(), address.addressLength) < 0)
throw coreutils::Exception("Error on bind to socket: " + std::to_string(errno));
throw coreutils::Exception("Error on bind to socket: " + std::to_string(errno));
if(listen(getDescriptor(), 10) < 0)
throw coreutils::Exception("Error on listen to socket");
throw coreutils::Exception("Error on listen to socket");
ePoll.registerSocket(this);
}
TCPServer::~TCPServer() {
close(getDescriptor());
}
void TCPServer::onDataReceived(std::string data) {
TCPSession *session = accept();
if(session) sessions.push_back(session);
@@ -29,24 +29,24 @@ namespace core {
TCPSession * TCPServer::accept() {
TCPSession *session = getSocketAccept(ePoll);
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;
// }
// 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;
// }
//
ePoll.registerSocket(session);
coreutils::Log(coreutils::LOG_DEBUG_2) << "Session started on socket " << session->getDescriptor() << ".";
return session;
}
void TCPServer::removeFromSessionList(TCPSession *session) {
std::vector<TCPSession *>::iterator cursor;
for(cursor = sessions.begin(); cursor < sessions.end(); ++cursor)