Merge branch 'develop' of ssh://barant.com/git/ServerCore into develop
This commit is contained in:
commit
86bd62221f
2
.gitignore
vendored
2
.gitignore
vendored
@ -6,3 +6,5 @@ Release
|
||||
libServerCore.a
|
||||
docs/latex/
|
||||
docs/html
|
||||
*/*.ipch
|
||||
*/mmap_address.bin
|
||||
|
||||
BIN
166339a69870102c/TCPServer.ipch
Normal file
BIN
166339a69870102c/TCPServer.ipch
Normal file
Binary file not shown.
BIN
166339a69870102c/mmap_address.bin
Normal file
BIN
166339a69870102c/mmap_address.bin
Normal file
Binary file not shown.
BIN
2353080d29599b0f/Socket.ipch
Normal file
BIN
2353080d29599b0f/Socket.ipch
Normal file
Binary file not shown.
BIN
2353080d29599b0f/mmap_address.bin
Normal file
BIN
2353080d29599b0f/mmap_address.bin
Normal file
Binary file not shown.
BIN
2727ac8b3b5f62c6/INotify.ipch
Normal file
BIN
2727ac8b3b5f62c6/INotify.ipch
Normal file
Binary file not shown.
BIN
2727ac8b3b5f62c6/mmap_address.bin
Normal file
BIN
2727ac8b3b5f62c6/mmap_address.bin
Normal file
Binary file not shown.
BIN
7faa46ef9a084930/mmap_address.bin
Normal file
BIN
7faa46ef9a084930/mmap_address.bin
Normal file
Binary file not shown.
BIN
83fc3f05cba9b549/ConsoleSession.ipch
Normal file
BIN
83fc3f05cba9b549/ConsoleSession.ipch
Normal file
Binary file not shown.
BIN
83fc3f05cba9b549/mmap_address.bin
Normal file
BIN
83fc3f05cba9b549/mmap_address.bin
Normal file
Binary file not shown.
BIN
8f1abf40eef9b0f/TCPSession.ipch
Normal file
BIN
8f1abf40eef9b0f/TCPSession.ipch
Normal file
Binary file not shown.
BIN
8f1abf40eef9b0f/mmap_address.bin
Normal file
BIN
8f1abf40eef9b0f/mmap_address.bin
Normal file
Binary file not shown.
BIN
9bd183291292c122/Thread.ipch
Normal file
BIN
9bd183291292c122/Thread.ipch
Normal file
Binary file not shown.
BIN
9bd183291292c122/mmap_address.bin
Normal file
BIN
9bd183291292c122/mmap_address.bin
Normal file
Binary file not shown.
@ -1,4 +1,5 @@
|
||||
#include "ConsoleSession.h"
|
||||
#include "TCPServer.h"
|
||||
#include "Log.h"
|
||||
|
||||
namespace core {
|
||||
@ -50,7 +51,7 @@ namespace core {
|
||||
|
||||
case PROCESS:
|
||||
doCommand(command);
|
||||
status = command.equals((char *)"exit") ? DONE: PROMPT;
|
||||
status = command.equals("exit") ? DONE: PROMPT;
|
||||
protocol(blank);
|
||||
break;
|
||||
|
||||
@ -65,9 +66,9 @@ namespace core {
|
||||
}
|
||||
|
||||
void ConsoleSession::writeLog(std::string data) {
|
||||
saveCursor();
|
||||
setCursorLocation(16, 1);
|
||||
restoreCursor();
|
||||
// saveCursor();
|
||||
// setCursorLocation(16, 1);
|
||||
// restoreCursor();
|
||||
}
|
||||
|
||||
void ConsoleSession::doCommand(coreutils::ZString &request) {
|
||||
|
||||
@ -2,11 +2,13 @@
|
||||
#define __ConsoleSession_h__
|
||||
|
||||
#include "TerminalSession.h"
|
||||
#include "TCPSession.h"
|
||||
//#include "TCPServer.h"
|
||||
#include "CommandList.h"
|
||||
|
||||
namespace core {
|
||||
|
||||
class TCPServer;
|
||||
|
||||
///
|
||||
/// ConsoleSession
|
||||
///
|
||||
|
||||
34
Socket.cpp
34
Socket.cpp
@ -1,6 +1,7 @@
|
||||
#include "EPoll.h"
|
||||
#include "Socket.h"
|
||||
#include "Exception.h"
|
||||
#include "ZString.h"
|
||||
#include "Log.h"
|
||||
|
||||
namespace core {
|
||||
@ -10,7 +11,7 @@ namespace core {
|
||||
buffer = (char *)malloc(4096);
|
||||
length = 4096;
|
||||
}
|
||||
|
||||
|
||||
Socket::~Socket() {
|
||||
free(buffer);
|
||||
if(descriptor == -1)
|
||||
@ -36,11 +37,11 @@ namespace core {
|
||||
onRegistered();
|
||||
lock.unlock();
|
||||
}
|
||||
|
||||
|
||||
int Socket::getDescriptor() {
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
|
||||
void Socket::setBufferSize(int length) {
|
||||
this->length = length;
|
||||
buffer = (char *)realloc(buffer, length);
|
||||
@ -50,7 +51,7 @@ namespace core {
|
||||
int Socket::getBufferSize() {
|
||||
return length;
|
||||
}
|
||||
|
||||
|
||||
void Socket::onRegister() {}
|
||||
|
||||
void Socket::onRegistered() {}
|
||||
@ -101,6 +102,8 @@ namespace core {
|
||||
|
||||
void Socket::receiveData(coreutils::ZString &buffer) {
|
||||
|
||||
coreutils::ZString blank("");
|
||||
|
||||
if(buffer.getLength() <= 0)
|
||||
throw coreutils::Exception("Request to receive data with a zero buffer length.", __FILE__, __LINE__, -1);
|
||||
|
||||
@ -113,22 +116,23 @@ namespace core {
|
||||
}
|
||||
else {
|
||||
|
||||
error = errno;
|
||||
error = errno;
|
||||
|
||||
switch (error) {
|
||||
switch (error) {
|
||||
|
||||
// When a listening socket receives a connection
|
||||
// request we get one of these.
|
||||
//
|
||||
case ENOTCONN:
|
||||
onDataReceived(std::string(buffer.getData(), 0));
|
||||
break;
|
||||
case ECONNRESET:
|
||||
// When a listening socket receives a connection
|
||||
// request we get one of these.
|
||||
//
|
||||
case ENOTCONN:
|
||||
onDataReceived(blank);
|
||||
break;
|
||||
|
||||
case ECONNRESET:
|
||||
break;
|
||||
|
||||
default:
|
||||
default:
|
||||
throw coreutils::Exception("Error in read of data from socket.", __FILE__, __LINE__, error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
2
Socket.h
2
Socket.h
@ -31,7 +31,7 @@ namespace core {
|
||||
/// receiving the EPOLLOUT event then the buffer is written to the socket output.
|
||||
///
|
||||
|
||||
class Socket : public core::Object {
|
||||
class Socket {
|
||||
|
||||
public:
|
||||
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -22,8 +22,8 @@ namespace core {
|
||||
|
||||
void TCPSession::onRegistered() {
|
||||
onConnected();
|
||||
coreutils::ZString nothing("");
|
||||
protocol(nothing);
|
||||
coreutils::ZString blank("");
|
||||
protocol(blank);
|
||||
send();
|
||||
if(term)
|
||||
shutdown("termination requested");
|
||||
@ -73,13 +73,13 @@ namespace core {
|
||||
if(term)
|
||||
shutdown("termination requested");
|
||||
}
|
||||
|
||||
|
||||
void TCPSession::onBlockReceived(coreutils::ZString &block) {
|
||||
coreutils::Log(coreutils::LOG_DEBUG_3) << "[" << block.getLength() << "]";
|
||||
if(term)
|
||||
shutdown("termination requested");
|
||||
}
|
||||
|
||||
|
||||
void TCPSession::send() {
|
||||
if(out.tellp() > 0)
|
||||
write(out.str());
|
||||
|
||||
@ -2,11 +2,11 @@
|
||||
#define __Terminal_h__
|
||||
|
||||
#include "includes"
|
||||
#include "TLSSession.h"
|
||||
#include "TCPSession.h"
|
||||
#include "TCPServer.h"
|
||||
|
||||
namespace core {
|
||||
|
||||
|
||||
static const int FG_BLACK = 30;
|
||||
static const int FG_RED = 31;
|
||||
static const int FG_GREEN = 32;
|
||||
@ -15,7 +15,7 @@ namespace core {
|
||||
static const int FG_MAGENTA = 35;
|
||||
static const int FG_CYAN = 36;
|
||||
static const int FG_WHITE = 37;
|
||||
|
||||
|
||||
static const int BG_BLACK = 40;
|
||||
static const int BG_RED = 41;
|
||||
static const int BG_GREEN = 42;
|
||||
|
||||
@ -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 << ".";
|
||||
}
|
||||
|
||||
|
||||
BIN
ad5e219de2997e96/ConsoleServer.ipch
Normal file
BIN
ad5e219de2997e96/ConsoleServer.ipch
Normal file
Binary file not shown.
BIN
ad5e219de2997e96/mmap_address.bin
Normal file
BIN
ad5e219de2997e96/mmap_address.bin
Normal file
Binary file not shown.
BIN
cb5b1eba9ad413e4/TerminalSession.ipch
Normal file
BIN
cb5b1eba9ad413e4/TerminalSession.ipch
Normal file
Binary file not shown.
BIN
cb5b1eba9ad413e4/mmap_address.bin
Normal file
BIN
cb5b1eba9ad413e4/mmap_address.bin
Normal file
Binary file not shown.
1
compile
1
compile
@ -31,3 +31,4 @@ echo -n "Building library documentation manual..."
|
||||
doxygen docs/latex/doxygen.sty >/dev/null 2>/dev/null
|
||||
echo "OK"
|
||||
|
||||
rm *.o
|
||||
BIN
d46db2862aa65619/TLSSession.ipch
Normal file
BIN
d46db2862aa65619/TLSSession.ipch
Normal file
Binary file not shown.
BIN
d46db2862aa65619/mmap_address.bin
Normal file
BIN
d46db2862aa65619/mmap_address.bin
Normal file
Binary file not shown.
BIN
ea542d94897942cc/mmap_address.bin
Normal file
BIN
ea542d94897942cc/mmap_address.bin
Normal file
Binary file not shown.
BIN
fddc56a344f3ae05/Command.ipch
Normal file
BIN
fddc56a344f3ae05/Command.ipch
Normal file
Binary file not shown.
BIN
fddc56a344f3ae05/mmap_address.bin
Normal file
BIN
fddc56a344f3ae05/mmap_address.bin
Normal file
Binary file not shown.
BIN
output/main
BIN
output/main
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user