mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-27 06:25:51 +00:00
Add auto-TLS support.
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
#include "../websocketpp/src/sockets/tls.hpp"
|
#include "../websocketpp/src/sockets/autotls.hpp"
|
||||||
#include "../websocketpp/src/websocketpp.hpp"
|
#include "../websocketpp/src/websocketpp.hpp"
|
||||||
|
|
||||||
#include "../json/value.h"
|
#include "../json/value.h"
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
|
|
||||||
#define WSDOOR_CPP
|
#define WSDOOR_CPP
|
||||||
#include "../websocketpp/src/sockets/tls.hpp"
|
#include "../websocketpp/src/sockets/autotls.hpp"
|
||||||
#include "../websocketpp/src/websocketpp.hpp"
|
#include "../websocketpp/src/websocketpp.hpp"
|
||||||
|
|
||||||
SETUP_LOG();
|
SETUP_LOG();
|
||||||
@@ -59,80 +59,40 @@ void WSDoor::startListening()
|
|||||||
|
|
||||||
SSL_CTX_set_tmp_dh_callback(mCtx->native_handle(), handleTmpDh);
|
SSL_CTX_set_tmp_dh_callback(mCtx->native_handle(), handleTmpDh);
|
||||||
|
|
||||||
if (mPublic ? theConfig.WEBSOCKET_PUBLIC_SECURE : theConfig.WEBSOCKET_SECURE)
|
// Construct a single handler for all requests.
|
||||||
|
websocketpp::server_autotls::handler::ptr handler(new WSServerHandler<websocketpp::server_autotls>(mCtx, mPublic));
|
||||||
|
|
||||||
|
// Construct a websocket server.
|
||||||
|
mSEndpoint = new websocketpp::server_autotls(handler);
|
||||||
|
|
||||||
|
// mEndpoint->alog().unset_level(websocketpp::log::alevel::ALL);
|
||||||
|
// mEndpoint->elog().unset_level(websocketpp::log::elevel::ALL);
|
||||||
|
|
||||||
|
// Call the main-event-loop of the websocket server.
|
||||||
|
try
|
||||||
{
|
{
|
||||||
// Construct a single handler for all requests.
|
mSEndpoint->listen(
|
||||||
websocketpp::server_tls::handler::ptr handler(new WSServerHandler<websocketpp::server_tls>(mCtx, mPublic));
|
boost::asio::ip::tcp::endpoint(
|
||||||
|
boost::asio::ip::address().from_string(mIp), mPort));
|
||||||
// Construct a websocket server.
|
}
|
||||||
mSEndpoint = new websocketpp::server_tls(handler);
|
catch (websocketpp::exception& e)
|
||||||
|
{
|
||||||
// mEndpoint->alog().unset_level(websocketpp::log::alevel::ALL);
|
cLog(lsWARNING) << "websocketpp exception: " << e.what();
|
||||||
// mEndpoint->elog().unset_level(websocketpp::log::elevel::ALL);
|
while (1) // temporary workaround for websocketpp throwing exceptions on access/close races
|
||||||
|
{ // https://github.com/zaphoyd/websocketpp/issues/98
|
||||||
// Call the main-event-loop of the websocket server.
|
try
|
||||||
try
|
{
|
||||||
{
|
mSEndpoint->get_io_service().run();
|
||||||
mSEndpoint->listen(
|
break;
|
||||||
boost::asio::ip::tcp::endpoint(
|
}
|
||||||
boost::asio::ip::address().from_string(mIp), mPort));
|
catch (websocketpp::exception& e)
|
||||||
}
|
{
|
||||||
catch (websocketpp::exception& e)
|
cLog(lsWARNING) << "websocketpp exception: " << e.what();
|
||||||
{
|
|
||||||
cLog(lsWARNING) << "websocketpp exception: " << e.what();
|
|
||||||
while (1) // temporary workaround for websocketpp throwing exceptions on access/close races
|
|
||||||
{ // https://github.com/zaphoyd/websocketpp/issues/98
|
|
||||||
try
|
|
||||||
{
|
|
||||||
mSEndpoint->get_io_service().run();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
catch (websocketpp::exception& e)
|
|
||||||
{
|
|
||||||
cLog(lsWARNING) << "websocketpp exception: " << e.what();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
delete mSEndpoint;
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
// Construct a single handler for all requests.
|
|
||||||
websocketpp::server::handler::ptr handler(new WSServerHandler<websocketpp::server>(mCtx, mPublic));
|
|
||||||
|
|
||||||
// Construct a websocket server.
|
delete mSEndpoint;
|
||||||
mEndpoint = new websocketpp::server(handler);
|
|
||||||
|
|
||||||
// mEndpoint->alog().unset_level(websocketpp::log::alevel::ALL);
|
|
||||||
// mEndpoint->elog().unset_level(websocketpp::log::elevel::ALL);
|
|
||||||
|
|
||||||
// Call the main-event-loop of the websocket server.
|
|
||||||
try
|
|
||||||
{
|
|
||||||
mEndpoint->listen(
|
|
||||||
boost::asio::ip::tcp::endpoint(
|
|
||||||
boost::asio::ip::address().from_string(mIp), mPort));
|
|
||||||
}
|
|
||||||
catch (websocketpp::exception& e)
|
|
||||||
{
|
|
||||||
cLog(lsWARNING) << "websocketpp exception: " << e.what();
|
|
||||||
while (1) // temporary workaround for websocketpp throwing exceptions on access/close races
|
|
||||||
{ // https://github.com/zaphoyd/websocketpp/issues/98
|
|
||||||
try
|
|
||||||
{
|
|
||||||
mEndpoint->get_io_service().run();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
catch (websocketpp::exception& e)
|
|
||||||
{
|
|
||||||
cLog(lsWARNING) << "websocketpp exception: " << e.what();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
delete mEndpoint;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WSDoor* WSDoor::createWSDoor(const std::string& strIp, const int iPort, bool bPublic)
|
WSDoor* WSDoor::createWSDoor(const std::string& strIp, const int iPort, bool bPublic)
|
||||||
@@ -154,8 +114,6 @@ void WSDoor::stop()
|
|||||||
{
|
{
|
||||||
if (mThread)
|
if (mThread)
|
||||||
{
|
{
|
||||||
if (mEndpoint)
|
|
||||||
mEndpoint->stop();
|
|
||||||
if (mSEndpoint)
|
if (mSEndpoint)
|
||||||
mSEndpoint->stop();
|
mSEndpoint->stop();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user