This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <unistd.h> | |
#include "LogBase.h" | |
using namespace util; | |
#include "MessageHandler.h" | |
int Main(int argc, char* argv[]) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef MESSAGEHANDLER_H | |
#define MESSAGEHANDLER_H | |
#include <string> | |
#include <stdio.h> | |
#include <limits.h> | |
#include <unistd.h> | |
#include <iostream> | |
#include <iomanip> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int MessageHandler::init() { | |
this->nm->Init(); | |
this->nm->connectCallbackHandler([this](string v, int type) { | |
return this->incomingHandler(v, type); | |
}); | |
} | |
void MessageHandler::start() { | |
this->nm->startService(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void NetworkManagerServer::Init() { | |
this->server = new Server(this->io_service, this->port); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Server::Server(boost::asio::io_service& io_service, int port) : io_service_(io_service), acceptor_(io_service, | |
boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(), port)), | |
context_(boost::asio::ssl::context::sslv23) { | |
this->context_.set_options(boost::asio::ssl::context::default_workarounds | |
| boost::asio::ssl::context::no_sslv2 | |
| boost::asio::ssl::context::single_dh_use); | |
this->context_.use_certificate_chain_file(Settings::server_crt); | |
this->context_.use_private_key_file(Settings::server_key, boost::asio::ssl::context::pem); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vector<string> MessageHandler::incomingHandler(string v, int type) { | |
vector<string> res; | |
string s; | |
bool ret; | |
switch (type) { | |
case RA_VERIFICATION: { //Verification request | |
Messages::InitialMessage init_msg; | |
ret = init_msg.ParseFromString(v); | |
if (ret && init_msg.type() == RA_VERIFICATION) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void MessageHandler::start() { | |
this->nm->startService(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void NetworkManagerServer::startService() { | |
this->server->start_accept(); | |
this->io_service.run(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <unistd.h> | |
#include "LogBase.h" | |
#include "NetworkManager.h" | |
#include "VerificationManager.h" | |
#include "UtilityFunctions.h" | |
using namespace util; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef VERIFICATIONMANAGER_H | |
#define VERIFICATIONMANAGER_H | |
#include <string> | |
#include <stdio.h> | |
#include <limits.h> | |
#include <unistd.h> | |
#include "ServiceProvider.h" | |
#include "NetworkManagerClient.h" |