Skip to content

Instantly share code, notes, and snippets.

View sangfansh's full-sized avatar

Fan Sang sangfansh

View GitHub Profile
#include <iostream>
#include <unistd.h>
#include "LogBase.h"
using namespace util;
#include "MessageHandler.h"
int Main(int argc, char* argv[]) {
#ifndef MESSAGEHANDLER_H
#define MESSAGEHANDLER_H
#include <string>
#include <stdio.h>
#include <limits.h>
#include <unistd.h>
#include <iostream>
#include <iomanip>
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();
void NetworkManagerServer::Init() {
this->server = new Server(this->io_service, this->port);
}
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);
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) {
void MessageHandler::start() {
this->nm->startService();
}
void NetworkManagerServer::startService() {
this->server->start_accept();
this->io_service.run();
}
#include <iostream>
#include <unistd.h>
#include "LogBase.h"
#include "NetworkManager.h"
#include "VerificationManager.h"
#include "UtilityFunctions.h"
using namespace util;
#ifndef VERIFICATIONMANAGER_H
#define VERIFICATIONMANAGER_H
#include <string>
#include <stdio.h>
#include <limits.h>
#include <unistd.h>
#include "ServiceProvider.h"
#include "NetworkManagerClient.h"