mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Remove theConfig dependency in PeerDoor
This commit is contained in:
@@ -6,26 +6,32 @@
|
||||
|
||||
SETUP_LOG (PeerDoor)
|
||||
|
||||
PeerDoor::PeerDoor (boost::asio::io_service& io_service) :
|
||||
mAcceptor (io_service,
|
||||
boost::asio::ip::tcp::endpoint (boost::asio::ip::address ().from_string (theConfig.PEER_IP.empty () ? "0.0.0.0" : theConfig.PEER_IP),
|
||||
theConfig.PEER_PORT)),
|
||||
mCtx (boost::asio::ssl::context::sslv23), mDelayTimer (io_service)
|
||||
// PEER_IP, PEER_PORT, PEER_SSL_CIPHER_LIST
|
||||
PeerDoor::PeerDoor (
|
||||
std::string const& ip,
|
||||
int port,
|
||||
std::string const& sslCiphers,
|
||||
boost::asio::io_service& io_service)
|
||||
: mAcceptor (
|
||||
io_service,
|
||||
boost::asio::ip::tcp::endpoint (boost::asio::ip::address ().from_string (ip.empty () ? "0.0.0.0" : ip),
|
||||
port))
|
||||
, mCtx (boost::asio::ssl::context::sslv23)
|
||||
, mDelayTimer (io_service)
|
||||
{
|
||||
mCtx.set_options (
|
||||
boost::asio::ssl::context::default_workarounds
|
||||
| boost::asio::ssl::context::no_sslv2
|
||||
| boost::asio::ssl::context::single_dh_use);
|
||||
boost::asio::ssl::context::default_workarounds |
|
||||
boost::asio::ssl::context::no_sslv2 |
|
||||
boost::asio::ssl::context::single_dh_use);
|
||||
|
||||
SSL_CTX_set_tmp_dh_callback (mCtx.native_handle (), handleTmpDh);
|
||||
|
||||
if (1 != SSL_CTX_set_cipher_list (mCtx.native_handle (), theConfig.PEER_SSL_CIPHER_LIST.c_str ()))
|
||||
if (SSL_CTX_set_cipher_list (mCtx.native_handle (), sslCiphers.c_str ()) != 1)
|
||||
std::runtime_error ("Error setting cipher list (no valid ciphers).");
|
||||
|
||||
|
||||
if (!theConfig.PEER_IP.empty () && theConfig.PEER_PORT)
|
||||
if (! ip.empty () && port != 0)
|
||||
{
|
||||
Log (lsINFO) << "Peer port: " << theConfig.PEER_IP << " " << theConfig.PEER_PORT;
|
||||
Log (lsINFO) << "Peer port: " << ip << " " << port;
|
||||
startListening ();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,10 @@ Handles incoming connections from other Peers
|
||||
class PeerDoor : LeakChecked <PeerDoor>
|
||||
{
|
||||
public:
|
||||
PeerDoor (boost::asio::io_service& io_service);
|
||||
PeerDoor (std::string const& ip,
|
||||
int port,
|
||||
std::string const& sslCiphers,
|
||||
boost::asio::io_service& io_service);
|
||||
|
||||
boost::asio::ssl::context& getSSLContext ()
|
||||
{
|
||||
|
||||
@@ -19,7 +19,8 @@ SETUP_LOG (WSDoor)
|
||||
// - We only talk to NetworkOPs (so we will work even in thin mode)
|
||||
// - NetworkOPs is smart enough to subscribe and or pass back messages
|
||||
//
|
||||
|
||||
// VFALCO NOTE NetworkOPs isn't used here...
|
||||
//
|
||||
void WSDoor::startListening ()
|
||||
{
|
||||
setCallingThreadName ("websocket");
|
||||
|
||||
@@ -569,7 +569,11 @@ void Application::setup ()
|
||||
{
|
||||
try
|
||||
{
|
||||
mPeerDoor = new PeerDoor (mIOService);
|
||||
mPeerDoor = new PeerDoor (
|
||||
theConfig.PEER_IP,
|
||||
theConfig.PEER_PORT,
|
||||
theConfig.PEER_SSL_CIPHER_LIST,
|
||||
mIOService);
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user