diff --git a/166339a69870102c/TCPServer.ipch b/166339a69870102c/TCPServer.ipch new file mode 100644 index 0000000..18fb373 Binary files /dev/null and b/166339a69870102c/TCPServer.ipch differ diff --git a/166339a69870102c/mmap_address.bin b/166339a69870102c/mmap_address.bin new file mode 100644 index 0000000..6fdd8d3 Binary files /dev/null and b/166339a69870102c/mmap_address.bin differ diff --git a/2353080d29599b0f/Socket.ipch b/2353080d29599b0f/Socket.ipch index 8b04b9c..abec078 100644 Binary files a/2353080d29599b0f/Socket.ipch and b/2353080d29599b0f/Socket.ipch differ diff --git a/83fc3f05cba9b549/ConsoleSession.ipch b/83fc3f05cba9b549/ConsoleSession.ipch index ace7ddf..31e71a5 100644 Binary files a/83fc3f05cba9b549/ConsoleSession.ipch and b/83fc3f05cba9b549/ConsoleSession.ipch differ diff --git a/8f1abf40eef9b0f/TCPSession.ipch b/8f1abf40eef9b0f/TCPSession.ipch index ae1ce6c..fc4b9ca 100644 Binary files a/8f1abf40eef9b0f/TCPSession.ipch and b/8f1abf40eef9b0f/TCPSession.ipch differ diff --git a/9bd183291292c122/Thread.ipch b/9bd183291292c122/Thread.ipch new file mode 100644 index 0000000..2b91caf Binary files /dev/null and b/9bd183291292c122/Thread.ipch differ diff --git a/9bd183291292c122/mmap_address.bin b/9bd183291292c122/mmap_address.bin new file mode 100644 index 0000000..65b9772 Binary files /dev/null and b/9bd183291292c122/mmap_address.bin differ diff --git a/ConsoleServer.cpp b/ConsoleServer.cpp index 3bbacd4..16cdc4f 100644 --- a/ConsoleServer.cpp +++ b/ConsoleServer.cpp @@ -5,7 +5,7 @@ namespace core { - ConsoleServer::ConsoleServer(EPoll &ePoll, IPAddress address) : TCPServer(ePoll, address, "Console") { + ConsoleServer::ConsoleServer(EPoll &ePoll, IPAddress address) : TCPServer(ePoll, address, " ", "Console") { coreutils::Log(this); } diff --git a/ConsoleSession.cpp b/ConsoleSession.cpp index b09694f..b51edab 100644 --- a/ConsoleSession.cpp +++ b/ConsoleSession.cpp @@ -1,9 +1,10 @@ #include "ConsoleSession.h" +#include "TCPServer.h" #include "Log.h" namespace core { - ConsoleSession::ConsoleSession(EPoll &ePoll, TCPServer &server) : TerminalSession(ePoll, server) { + ConsoleSession::ConsoleSession(EPoll &ePoll, TCPServer &server) : TCPSession(ePoll, server) { coreutils::Log(coreutils::LOG_DEBUG_2) << "Constructing ConsoleSession..."; } @@ -16,21 +17,12 @@ namespace core { switch (status) { case WELCOME: - setBackColor(BG_BLACK); - clear(); - setCursorLocation(1, 1); - setBackColor(BG_BLUE); - clearEOL(); - out << "ConsoleSession"; - setCursorLocation(2, 1); - setBackColor(BG_BLACK); status = LOGIN; protocol(blank); break; case LOGIN: - setCursorLocation(3, 3); - out << "Enter User Profile: "; + out << "User: "; status = WAIT_USER_PROFILE; break; @@ -40,29 +32,17 @@ namespace core { break; case PASSWORD: - setCursorLocation(4, 7); - out << "Enter Password: "; + out << "Password: "; status = WAIT_PASSWORD; break; case WAIT_PASSWORD: - setBackColor(BG_BLACK); - clear(); - setCursorLocation(1, 1); - setBackColor(BG_BLUE); - clearEOL(); - out << "ConsoleSession"; - setCursorLocation(2, 1); - setBackColor(BG_BLACK); - scrollArea(2, 16); status = PROMPT; protocol(blank); break; case PROMPT: - setCursorLocation(17, 1); - clearEOL(); - out << ("--> "); + out << (": "); status = INPUT; break; @@ -89,17 +69,17 @@ namespace core { } void ConsoleSession::writeLog(std::string data) { - saveCursor(); - setCursorLocation(16, 1); - restoreCursor(); + // saveCursor(); + // setCursorLocation(16, 1); + // restoreCursor(); } void ConsoleSession::doCommand(coreutils::ZString request) { - saveCursor(); - setCursorLocation(16, 1); - out << "--> " << request << std::endl; + // saveCursor(); + // setCursorLocation(16, 1); + // out << "--> " << request << std::endl; server.commands.processRequest(request, *this); - restoreCursor(); + // restoreCursor(); } } diff --git a/ConsoleSession.h b/ConsoleSession.h index 0e261ea..3d3f011 100644 --- a/ConsoleSession.h +++ b/ConsoleSession.h @@ -1,7 +1,7 @@ #ifndef __ConsoleSession_h__ #define __ConsoleSession_h__ -#include "TerminalSession.h" +//#include "TerminalSession.h" #include "TCPSession.h" #include "CommandList.h" @@ -15,7 +15,7 @@ namespace core { /// protocol interaction for this socket which is a console session. /// - class ConsoleSession : public TerminalSession { + class ConsoleSession : public TCPSession { public: ConsoleSession(EPoll &ePoll, TCPServer &server); diff --git a/Socket.cpp b/Socket.cpp index 7e054fd..bf53460 100644 --- a/Socket.cpp +++ b/Socket.cpp @@ -100,7 +100,9 @@ namespace core { } void Socket::receiveData(coreutils::ZString &buffer) { - + + coreutils::ZString empty(""); + if(buffer.getLength() <= 0) throw coreutils::Exception("Request to receive data with a zero buffer length.", __FILE__, __LINE__, -1); @@ -117,12 +119,12 @@ namespace core { switch (error) { - // When a listening socket receives a connection - // request we get one of these. - // - case ENOTCONN: - onDataReceived(std::string(buffer.getData(), 0)); - break; + // When a listening socket receives a connection + // request we get one of these. + // + case ENOTCONN: + onDataReceived(empty); + break; case ECONNRESET: break; diff --git a/TCPServer.cpp b/TCPServer.cpp index edba41d..cc89dd6 100644 --- a/TCPServer.cpp +++ b/TCPServer.cpp @@ -32,8 +32,11 @@ namespace core { } TCPSession * TCPServer::accept() { - TCPSession *session = getSocketAccept(ePoll); - session->setDescriptor(::accept(getDescriptor(), (struct sockaddr *)&session->ipAddress.addr, &session->ipAddress.addressLength)); + + try { + + 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."; @@ -44,8 +47,16 @@ namespace core { // 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; + coreutils::Log(coreutils::LOG_DEBUG_2) << "Session started on socket " << session->getDescriptor() << "."; + return session; + } + catch(coreutils::Exception e) { + coreutils::Log(coreutils::LOG_EXCEPT) << "Major error on session initialization. Error is '" << e.text << "'."; + } + catch(...) { + coreutils::Log(coreutils::LOG_EXCEPT) << "Unnspecified error on session initialization."; + } + return NULL; } void TCPServer::removeFromSessionList(TCPSession *session) { diff --git a/Thread.cpp b/Thread.cpp index 12f8f4c..4464439 100644 --- a/Thread.cpp +++ b/Thread.cpp @@ -60,10 +60,10 @@ namespace core { for(int ix = 0; ix < rc; ++ix) { ++count; if(((Socket *)events[ix].data.ptr)->eventReceived(events[ix])) - ePoll.resetSocket((Socket *)events[ix].data.ptr); - } - } - } + ePoll.resetSocket((Socket *)events[ix].data.ptr); + } + } + } coreutils::Log(coreutils::LOG_DEBUG_1) << "Thread ending with thread id " << threadId << "."; } diff --git a/ad5e219de2997e96/ConsoleServer.ipch b/ad5e219de2997e96/ConsoleServer.ipch new file mode 100644 index 0000000..b8541d1 Binary files /dev/null and b/ad5e219de2997e96/ConsoleServer.ipch differ diff --git a/ad5e219de2997e96/mmap_address.bin b/ad5e219de2997e96/mmap_address.bin new file mode 100644 index 0000000..395203a Binary files /dev/null and b/ad5e219de2997e96/mmap_address.bin differ diff --git a/cb5b1eba9ad413e4/TerminalSession.ipch b/cb5b1eba9ad413e4/TerminalSession.ipch new file mode 100644 index 0000000..0dfffd0 Binary files /dev/null and b/cb5b1eba9ad413e4/TerminalSession.ipch differ diff --git a/cb5b1eba9ad413e4/mmap_address.bin b/cb5b1eba9ad413e4/mmap_address.bin new file mode 100644 index 0000000..e4e6926 Binary files /dev/null and b/cb5b1eba9ad413e4/mmap_address.bin differ diff --git a/d46db2862aa65619/TLSSession.ipch b/d46db2862aa65619/TLSSession.ipch index c156416..33eaa08 100644 Binary files a/d46db2862aa65619/TLSSession.ipch and b/d46db2862aa65619/TLSSession.ipch differ