Don't create peer doors in standalone mode

This commit is contained in:
Nik Bougalis
2014-03-26 17:36:33 -07:00
parent c51644f1b9
commit 166b8963bb
3 changed files with 28 additions and 22 deletions

View File

@@ -148,10 +148,11 @@ PeerDoor::PeerDoor (Stoppable& parent)
}
//------------------------------------------------------------------------------
PeerDoor* PeerDoor::New (
Kind kind, Peers& peers,
std::unique_ptr<PeerDoor>
createPeerDoor (
PeerDoor::Kind kind, Peers& peers,
std::string const& ip, int port,
boost::asio::io_service& io_service)
boost::asio::io_service& io_service)
{
// You have to listen on something!
bassert(port != 0);
@@ -160,7 +161,7 @@ PeerDoor* PeerDoor::New (
boost::asio::ip::address ().from_string (
ip.empty () ? "0.0.0.0" : ip), port);
return new PeerDoorImp (kind, peers, ep, io_service);
return std::make_unique<PeerDoorImp>(kind, peers, ep, io_service);
}
}

View File

@@ -20,6 +20,8 @@
#ifndef RIPPLE_PEERDOOR_H_INCLUDED
#define RIPPLE_PEERDOOR_H_INCLUDED
#include "../../beast/beast/cxx14/memory.h" // <memory>
namespace ripple {
/** Handles incoming connections from peers. */
@@ -36,12 +38,14 @@ public:
sslRequired,
sslAndPROXYRequired
};
static PeerDoor* New (Kind kind, Peers& peers,
std::string const& ip, int port,
boost::asio::io_service& io_service);
};
std::unique_ptr <PeerDoor>
createPeerDoor (
PeerDoor::Kind kind, Peers& peers,
std::string const& ip, int port,
boost::asio::io_service& io_service);
}
#endif

View File

@@ -453,23 +453,24 @@ public:
// Configure the peer doors, which allow the server to accept incoming
// peer connections:
// Create the listening sockets for peers
//
m_doorDirect.reset (PeerDoor::New (
PeerDoor::sslRequired,
*this,
getConfig ().PEER_IP,
getConfig ().peerListeningPort,
m_io_service));
if (getConfig ().peerPROXYListeningPort != 0)
if (! getConfig ().RUN_STANDALONE)
{
m_doorProxy.reset (PeerDoor::New (
PeerDoor::sslAndPROXYRequired,
m_doorDirect = createPeerDoor (
PeerDoor::sslRequired,
*this,
getConfig ().PEER_IP,
getConfig ().peerPROXYListeningPort,
m_io_service));
getConfig ().peerListeningPort,
m_io_service);
if (getConfig ().peerPROXYListeningPort != 0)
{
m_doorProxy = createPeerDoor (
PeerDoor::sslAndPROXYRequired,
*this,
getConfig ().PEER_IP,
getConfig ().peerPROXYListeningPort,
m_io_service);
}
}
}