From 510ce3bec7915a790fbf75ace5521e437d9d416a Mon Sep 17 00:00:00 2001 From: Dennis Brentjes Date: Fri, 21 Oct 2016 14:01:26 +0200 Subject: Adds SSL connections between nodes. --- libcmix-common/receiver.hpp | 28 ++++++++++++++++++++++++ libcmix-common/sender.hpp | 31 ++++++++++++++++++++++++++ libcmix-common/senderreceiver.cpp | 9 -------- libcmix-common/senderreceiver.hpp | 46 ++++++++++++++++++++++++++++++++++++--- 4 files changed, 102 insertions(+), 12 deletions(-) (limited to 'libcmix-common') diff --git a/libcmix-common/receiver.hpp b/libcmix-common/receiver.hpp index 8a73e9c..efd3753 100644 --- a/libcmix-common/receiver.hpp +++ b/libcmix-common/receiver.hpp @@ -21,6 +21,7 @@ struct Receiver : private ProtobufClient friend SenderReceiver; using ProtobufClient::ProtobufClient; + using ProtobufClient::operator=; using ProtobufClient::async_receive; @@ -32,3 +33,30 @@ struct Receiver : private ProtobufClient using ProtobufClient::is_open; }; + +struct SSLSenderReceiver; + +/*! + * \brief The Receiver struct is a shim around ProtobufClient and only exposes things needed + * for receiving messages. + */ +struct SSLReceiver : private SSLProtobufClient +{ + /*! + * \brief friend decleration allowing Receivers to be upgraded to SenderReceivers. + */ + friend SSLSenderReceiver; + + using SSLProtobufClient::SSLProtobufClient; + using SSLProtobufClient::operator=; + + using SSLProtobufClient::async_receive; + + using SSLProtobufClient::async_connect; + + using SSLProtobufClient::close; + + using SSLProtobufClient::on_done; + + using SSLProtobufClient::is_open; +}; diff --git a/libcmix-common/sender.hpp b/libcmix-common/sender.hpp index ea16a81..c722e30 100644 --- a/libcmix-common/sender.hpp +++ b/libcmix-common/sender.hpp @@ -25,6 +25,7 @@ struct Sender : private ProtobufClient friend SenderReceiver; using ProtobufClient::ProtobufClient; + using ProtobufClient::operator=; using ProtobufClient::async_send; @@ -36,3 +37,33 @@ struct Sender : private ProtobufClient using ProtobufClient::is_open; }; + +/*! + * \brief forward declaration for SenderReceiver to allow for the friend declaration. + */ +struct SSLSenderReceiver; + +/*! + * \brief The Sender struct is a shim around ProtobufClient and only exposes things needed + * for sending messages. + */ +struct SSLSender : private SSLProtobufClient +{ + /*! + * The friend declaration that allows for the Sender to be upgraded to a SenderReceiver. + */ + friend SSLSenderReceiver; + + using SSLProtobufClient::SSLProtobufClient; + using SSLProtobufClient::operator=; + + using SSLProtobufClient::async_send; + + using SSLProtobufClient::async_connect; + + using SSLProtobufClient::close; + + using SSLProtobufClient::on_done; + + using SSLProtobufClient::is_open; +}; diff --git a/libcmix-common/senderreceiver.cpp b/libcmix-common/senderreceiver.cpp index eafa8a5..8b13789 100644 --- a/libcmix-common/senderreceiver.cpp +++ b/libcmix-common/senderreceiver.cpp @@ -1,10 +1 @@ -#include "senderreceiver.hpp" - -SenderReceiver::SenderReceiver(Receiver&& r) -: ProtobufClient(std::move(r)) -{} - -SenderReceiver::SenderReceiver(Sender&& s) -: ProtobufClient(std::move(s)) -{} diff --git a/libcmix-common/senderreceiver.hpp b/libcmix-common/senderreceiver.hpp index c7fed3a..6654809 100644 --- a/libcmix-common/senderreceiver.hpp +++ b/libcmix-common/senderreceiver.hpp @@ -20,15 +20,20 @@ struct SenderReceiver : private ProtobufClient * \brief SenderReceiver Explicit conversion to SenderReceiver * \param r The Receiver to upgrade */ - explicit SenderReceiver(Receiver&& r); + explicit SenderReceiver(Receiver&& r) + : ProtobufClient(std::move(r)) + {} /*! * \brief SenderReceiver Explicit conversion to SenderReceiver * \param s The Sender to upgrade */ - explicit SenderReceiver(Sender&& s); + explicit SenderReceiver(Sender&& s) + : ProtobufClient(std::move(s)) + {} using ProtobufClient::ProtobufClient; + using ProtobufClient::operator=; using ProtobufClient::async_receive; @@ -41,4 +46,39 @@ struct SenderReceiver : private ProtobufClient using ProtobufClient::on_done; using ProtobufClient::is_open; -}; \ No newline at end of file +}; + +struct SSLSenderReceiver : private SSLProtobufClient +{ + /*! + * \brief SenderReceiver Explicit conversion to SenderReceiver + * \param r The Receiver to upgrade + */ + explicit SSLSenderReceiver(SSLReceiver&& r) + : SSLProtobufClient(std::move(r)) + {} + + /*! + * \brief SenderReceiver Explicit conversion to SenderReceiver + * \param s The Sender to upgrade + */ + explicit SSLSenderReceiver(SSLSender&& s) + : SSLProtobufClient(std::move(s)) + {} + + using SSLProtobufClient::SSLProtobufClient; + using SSLProtobufClient::operator=; + + using SSLProtobufClient::async_receive; + + using SSLProtobufClient::async_send; + + using SSLProtobufClient::async_connect; + + using SSLProtobufClient::close; + + using SSLProtobufClient::on_done; + + using SSLProtobufClient::is_open; +}; + -- cgit v1.2.3-70-g09d2