diff options
| author | Gordon Sim <gsim@apache.org> | 2011-10-20 19:40:34 +0000 |
|---|---|---|
| committer | Gordon Sim <gsim@apache.org> | 2011-10-20 19:40:34 +0000 |
| commit | 5a5e2ab9a595836f3aff296d6ca1779ebcaa0274 (patch) | |
| tree | e6c964011fdef6d22ac28dc93bd6fdeec6fef931 /cpp/src/qpid/sys/TCPIOPlugin.cpp | |
| parent | 0d07c91a8bcedcecce2053906874e28290b90de8 (diff) | |
| download | qpid-python-5a5e2ab9a595836f3aff296d6ca1779ebcaa0274.tar.gz | |
QPID-3514: Allow SSL and non-SSL connections on the same port. Applied patch from Zane Bitter and added simple test case.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1187011 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/sys/TCPIOPlugin.cpp')
| -rw-r--r-- | cpp/src/qpid/sys/TCPIOPlugin.cpp | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/cpp/src/qpid/sys/TCPIOPlugin.cpp b/cpp/src/qpid/sys/TCPIOPlugin.cpp index 85d8c1db87..8a99d8db71 100644 --- a/cpp/src/qpid/sys/TCPIOPlugin.cpp +++ b/cpp/src/qpid/sys/TCPIOPlugin.cpp @@ -43,7 +43,7 @@ class AsynchIOProtocolFactory : public ProtocolFactory { uint16_t listeningPort; public: - AsynchIOProtocolFactory(const std::string& host, const std::string& port, int backlog, bool nodelay); + AsynchIOProtocolFactory(const std::string& host, const std::string& port, int backlog, bool nodelay, bool shouldListen); void accept(Poller::shared_ptr, ConnectionCodec::Factory*); void connect(Poller::shared_ptr, const std::string& host, const std::string& port, ConnectionCodec::Factory*, @@ -57,6 +57,20 @@ class AsynchIOProtocolFactory : public ProtocolFactory { void connectFailed(const Socket&, int, const std::string&, ConnectFailedCallback); }; +static bool sslMultiplexEnabled(void) +{ + Options o; + Plugin::addOptions(o); + + if (o.find_nothrow("ssl-multiplex", false)) { + // This option is added by the SSL plugin when the SSL port + // is configured to be the same as the main port. + QPID_LOG(notice, "SSL multiplexing enabled"); + return true; + } + return false; +} + // Static instance to initialise plugin static class TCPIOPlugin : public Plugin { void earlyInitialize(Target&) { @@ -67,20 +81,31 @@ static class TCPIOPlugin : public Plugin { // Only provide to a Broker if (broker) { const broker::Broker::Options& opts = broker->getOptions(); + + // Check for SSL on the same port + bool shouldListen = !sslMultiplexEnabled(); + ProtocolFactory::shared_ptr protocolt( new AsynchIOProtocolFactory( "", boost::lexical_cast<std::string>(opts.port), opts.connectionBacklog, - opts.tcpNoDelay)); - QPID_LOG(notice, "Listening on TCP/TCP6 port " << protocolt->getPort()); + opts.tcpNoDelay, + shouldListen)); + if (shouldListen) { + QPID_LOG(notice, "Listening on TCP/TCP6 port " << protocolt->getPort()); + } broker->registerProtocolFactory("tcp", protocolt); } } } tcpPlugin; -AsynchIOProtocolFactory::AsynchIOProtocolFactory(const std::string& host, const std::string& port, int backlog, bool nodelay) : +AsynchIOProtocolFactory::AsynchIOProtocolFactory(const std::string& host, const std::string& port, int backlog, bool nodelay, bool shouldListen) : tcpNoDelay(nodelay) { + if (!shouldListen) { + return; + } + SocketAddress sa(host, port); // We must have at least one resolved address |
