Paul Zinselmeyer
ba8e969470
All checks were successful
Latex Build / build-latex (Assignment 4 - Protokollsicherheit (Praxis)) (push) Successful in 1m2s
Latex Build / build-latex (Assignment 5 - Software Security - Teil 1) (push) Successful in 1m3s
Latex Build / build-latex (Assignment 6 - Software Security - Teil 2) (push) Successful in 1m0s
Latex Build / build-latex (Assignment 4 - Protokollsicherheit (Praxis)) (pull_request) Successful in 30s
Latex Build / build-latex (Assignment 5 - Software Security - Teil 1) (pull_request) Successful in 10s
Latex Build / build-latex (Assignment 6 - Software Security - Teil 2) (pull_request) Successful in 8s
53 lines
1.5 KiB
C++
53 lines
1.5 KiB
C++
#include "Server.h"
|
|
#include "../GeneralSettings.h"
|
|
|
|
using namespace util;
|
|
|
|
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);
|
|
|
|
Log("Certificate \"" + Settings::server_crt + "\" set");
|
|
Log("Server running on port: %d", port);
|
|
}
|
|
|
|
|
|
Server::~Server() {}
|
|
|
|
|
|
void Server::start_accept() {
|
|
Session *new_session = new Session(io_service_, context_);
|
|
new_session->setCallbackHandler(this->callback_handler);
|
|
acceptor_.async_accept(new_session->socket(), boost::bind(&Server::handle_accept, this, new_session, boost::asio::placeholders::error));
|
|
}
|
|
|
|
|
|
void Server::handle_accept(Session* new_session, const boost::system::error_code& error) {
|
|
if (!error) {
|
|
Log("New accept request, starting new session");
|
|
new_session->start();
|
|
} else {
|
|
delete new_session;
|
|
}
|
|
|
|
start_accept();
|
|
}
|
|
|
|
void Server::connectCallbackHandler(CallbackHandler cb) {
|
|
this->callback_handler = cb;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|