From c9bdcc3cfdafb1bc71e864658e04931371cc44bf Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Wed, 23 Jan 2013 14:14:28 -0800 Subject: [PATCH] Tweaks. --- src/cpp/ripple/AutoSocket.cpp | 1 + src/cpp/ripple/AutoSocket.h | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/cpp/ripple/AutoSocket.cpp b/src/cpp/ripple/AutoSocket.cpp index 732716194e..dd553a4c57 100644 --- a/src/cpp/ripple/AutoSocket.cpp +++ b/src/cpp/ripple/AutoSocket.cpp @@ -25,6 +25,7 @@ void AutoSocket::handle_autodetect(const error_code& ec) { // ssl mSecure = true; SSLSocket().async_handshake(ssl_socket::server, mCallback); + mCallback = callback(); } } diff --git a/src/cpp/ripple/AutoSocket.h b/src/cpp/ripple/AutoSocket.h index 019618dbd8..d8529ea282 100644 --- a/src/cpp/ripple/AutoSocket.h +++ b/src/cpp/ripple/AutoSocket.h @@ -10,7 +10,8 @@ // Socket wrapper that supports both SSL and non-SSL connections. // Generally, handle it as you would an SSL connection. -// For outbound non-SSL connections, just don't call async_handshake. +// To force a non-SSL connection, just don't call async_handshake. +// To force SSL only inbound, call setSSLOnly. namespace basio = boost::asio; namespace bassl = basio::ssl; @@ -37,10 +38,12 @@ public: ssl_socket& SSLSocket() { return mSocket; } plain_socket& PlainSocket() { return mSocket.next_layer(); } + void setSSLOnly() { mBuffer.clear(); } + void async_handshake(ssl_socket::handshake_type type, callback cbFunc) { mSecure = true; - if (type == ssl_socket::client) + if ((type == ssl_socket::client) || (mBuffer.empty())) SSLSocket().async_handshake(type, cbFunc); else { @@ -92,3 +95,5 @@ protected: }; #endif + +// vim:ts=4