summaryrefslogtreecommitdiff
path: root/cpp/src/qpid/sys/SslPlugin.cpp
diff options
context:
space:
mode:
authorAndrew Stitcher <astitcher@apache.org>2012-10-24 05:51:19 +0000
committerAndrew Stitcher <astitcher@apache.org>2012-10-24 05:51:19 +0000
commit29d3d257a0df2e3f9d0386e534411c7f3806fa85 (patch)
treebaabe1be2b4389b3412154598fe0ea543ddd63f5 /cpp/src/qpid/sys/SslPlugin.cpp
parent47335b1ed3e73868cb80432f8479545bcb617fee (diff)
downloadqpid-python-29d3d257a0df2e3f9d0386e534411c7f3806fa85.tar.gz
QPID-4272: Large amounts of code are duplicated between the SSL and TCP transports
Refactor to unify the various SSL and TCP interfaces: - Make ssl listen have the same signature as regular sockets - Give ssl connect same interface as tcp - Unify the SSL and TCP IO interfaces some more git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1401558 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/sys/SslPlugin.cpp')
-rw-r--r--cpp/src/qpid/sys/SslPlugin.cpp35
1 files changed, 22 insertions, 13 deletions
diff --git a/cpp/src/qpid/sys/SslPlugin.cpp b/cpp/src/qpid/sys/SslPlugin.cpp
index c14cb5f016..1cebadeab3 100644
--- a/cpp/src/qpid/sys/SslPlugin.cpp
+++ b/cpp/src/qpid/sys/SslPlugin.cpp
@@ -29,6 +29,7 @@
#include "qpid/sys/AsynchIO.h"
#include "qpid/sys/ssl/SslIo.h"
#include "qpid/sys/ssl/SslSocket.h"
+#include "qpid/sys/SocketAddress.h"
#include "qpid/broker/Broker.h"
#include "qpid/log/Statement.h"
@@ -68,8 +69,6 @@ template <class T>
class SslProtocolFactoryTmpl : public ProtocolFactory {
private:
- typedef SslAcceptorTmpl<T> SslAcceptor;
-
Timer& brokerTimer;
uint32_t maxNegotiateTime;
const bool tcpNoDelay;
@@ -79,7 +78,10 @@ class SslProtocolFactoryTmpl : public ProtocolFactory {
bool nodict;
public:
- SslProtocolFactoryTmpl(const SslServerOptions&, int backlog, bool nodelay, Timer& timer, uint32_t maxTime);
+ SslProtocolFactoryTmpl(const std::string& host, const std::string& port,
+ const SslServerOptions&,
+ int backlog, bool nodelay,
+ Timer& timer, uint32_t maxTime);
void accept(Poller::shared_ptr, ConnectionCodec::Factory*);
void connect(Poller::shared_ptr, const std::string& host, const std::string& port,
ConnectionCodec::Factory*,
@@ -139,14 +141,16 @@ static struct SslPlugin : public Plugin {
const broker::Broker::Options& opts = broker->getOptions();
ProtocolFactory::shared_ptr protocol(options.multiplex ?
- static_cast<ProtocolFactory*>(new SslMuxProtocolFactory(options,
- opts.connectionBacklog,
- opts.tcpNoDelay,
- broker->getTimer(), opts.maxNegotiateTime)) :
- static_cast<ProtocolFactory*>(new SslProtocolFactory(options,
- opts.connectionBacklog,
- opts.tcpNoDelay,
- broker->getTimer(), opts.maxNegotiateTime)));
+ static_cast<ProtocolFactory*>(new SslMuxProtocolFactory("", boost::lexical_cast<std::string>(options.port),
+ options,
+ opts.connectionBacklog,
+ opts.tcpNoDelay,
+ broker->getTimer(), opts.maxNegotiateTime)) :
+ static_cast<ProtocolFactory*>(new SslProtocolFactory("", boost::lexical_cast<std::string>(options.port),
+ options,
+ opts.connectionBacklog,
+ opts.tcpNoDelay,
+ broker->getTimer(), opts.maxNegotiateTime)));
QPID_LOG(notice, "Listening for " <<
(options.multiplex ? "SSL or TCP" : "SSL") <<
" connections on TCP port " <<
@@ -161,10 +165,15 @@ static struct SslPlugin : public Plugin {
} sslPlugin;
template <class T>
-SslProtocolFactoryTmpl<T>::SslProtocolFactoryTmpl(const SslServerOptions& options, int backlog, bool nodelay, Timer& timer, uint32_t maxTime) :
+SslProtocolFactoryTmpl<T>::SslProtocolFactoryTmpl(const std::string& host, const std::string& port,
+ const SslServerOptions& options,
+ int backlog, bool nodelay,
+ Timer& timer, uint32_t maxTime) :
brokerTimer(timer),
maxNegotiateTime(maxTime),
- tcpNoDelay(nodelay), listeningPort(listener.listen(options.port, backlog, options.certName, options.clientAuth)),
+ tcpNoDelay(nodelay),
+ listener(options.certName, options.clientAuth),
+ listeningPort(listener.listen(SocketAddress(host, port), backlog)),
nodict(options.nodict)
{}