diff --git a/src/cpp/ripple/WSConnection.cpp b/src/cpp/ripple/WSConnection.cpp deleted file mode 100644 index 136e7304d5..0000000000 --- a/src/cpp/ripple/WSConnection.cpp +++ /dev/null @@ -1,102 +0,0 @@ -// -// WSConnection -// - -#include "Log.h" - -SETUP_LOG(); - -#include "CallRPC.h" // XXX Remove this, don't provide support for RPC syntax. -#include "WSConnection.h" -#include "WSHandler.h" - -#include "../json/reader.h" -#include "../json/writer.h" - - -//template -//WSConnection::~WSConnection() - -//template WSConnection::~WSConnection(); -//template WSConnection::~WSConnection(); - -template -void WSConnection::send(const Json::Value& jvObj) -{ - mHandler->send(mConnection, jvObj); -} -template void WSConnection::send(const Json::Value& jvObj); -template void WSConnection::send(const Json::Value& jvObj); - -// -// Utilities -// -template -Json::Value WSConnection::invokeCommand(Json::Value& jvRequest) -{ - if (!jvRequest.isMember("command")) - { - Json::Value jvResult(Json::objectValue); - - jvResult["type"] = "response"; - jvResult["result"] = "error"; - jvResult["error"] = "missingCommand"; - jvResult["command"] = jvRequest; - - return jvResult; - } - - RPCHandler mRPCHandler(&mNetwork, this); - Json::Value jvResult(Json::objectValue); - - // XXX Temporarily support RPC style commands over websocket. Remove this. - if (jvRequest.isMember("params")) - { - RPCParser rpParser; - - Json::Value jvRpcRequest = rpParser.parseCommand(jvRequest["command"].asString(), jvRequest["params"]); - - if (jvRpcRequest.isMember("error")) - { - jvResult = jvRpcRequest; - } - else - { - jvResult["result"] = mRPCHandler.doCommand( - jvRpcRequest, - mHandler->getPublic() ? RPCHandler::GUEST : RPCHandler::ADMIN); - } - } - else - { - jvResult["result"] = mRPCHandler.doCommand( - jvRequest, - mHandler->getPublic() ? RPCHandler::GUEST : RPCHandler::ADMIN); - } - - // Currently we will simply unwrap errors returned by the RPC - // API, in the future maybe we can make the responses - // consistent. - // - // Regularize result. This is duplicate code. - if (jvResult["result"].isMember("error")) - { - jvResult = jvResult["result"]; - jvResult["status"] = "error"; - jvResult["request"] = jvRequest; - - } else { - jvResult["status"] = "success"; - } - - if (jvRequest.isMember("id")) - { - jvResult["id"] = jvRequest["id"]; - } - - jvResult["type"] = "response"; - - return jvResult; -} - -// vim:ts=4 diff --git a/src/cpp/ripple/WSHandler.h b/src/cpp/ripple/WSHandler.h index 6e2b40cf2c..3a90c6d456 100644 --- a/src/cpp/ripple/WSHandler.h +++ b/src/cpp/ripple/WSHandler.h @@ -76,7 +76,7 @@ public: { boost::mutex::scoped_lock sl(mMapLock); - mMap[cpClient] = boost::make_shared(this, cpClient); + mMap[cpClient] = boost::make_shared< WSConnection >(this, cpClient); } void on_close(connection_ptr cpClient) @@ -115,7 +115,7 @@ public: } else { - boost::shared_ptr conn; + boost::shared_ptr< WSConnection > conn; { boost::mutex::scoped_lock sl(mMapLock); conn = mMap[cpClient]; @@ -136,9 +136,11 @@ public: context->set_options(boost::asio::ssl::context::default_workarounds | boost::asio::ssl::context::no_sslv2 | boost::asio::ssl::context::single_dh_use); - context->set_password_callback(boost::bind(&type::get_password, this)); - context->use_certificate_chain_file(theConfig.WEBSOCKET_SSL_CERT); - context->use_private_key_file(theConfig.WEBSOCKET_SSL_CERT, boost::asio::ssl::context::pem); +// context->set_password_callback(boost::bind(&type::get_password, this)); + if (!theConfig.WEBSOCKET_SSL_CERT.empty()) + context->use_private_key_file(theConfig.WEBSOCKET_SSL_CERT, boost::asio::ssl::context::pem); + if (!theConfig.WEBSOCKET_SSL_CHAIN.empty()) + context->use_certificate_chain_file(theConfig.WEBSOCKET_SSL_CHAIN); //context->use_tmp_dh_file("../../src/ssl/dh512.pem"); } catch (std::exception& e) { std::cout << e.what() << std::endl;