Report the inbound listening port during crawl (RIPD-866)

This commit is contained in:
seelabs
2015-04-23 10:55:38 -07:00
committed by Vinnie Falco
parent aa5d16b3d8
commit c8447c190c
5 changed files with 34 additions and 2 deletions

View File

@@ -595,12 +595,21 @@ OverlayImpl::crawl()
pv[jss::public_key] = beast::base64_encode(
sp->getNodePublic().getNodePublic().data(),
sp->getNodePublic().getNodePublic().size());
pv[jss::type] = sp->slot()->inbound() ?
"in" : "out";
if (sp->crawl())
{
pv[jss::ip] = sp->getRemoteAddress().address().to_string();
if (sp->slot()->inbound())
pv[jss::ip] = sp->getRemoteAddress().address().to_string();
{
if (auto port = sp->slot()->listening_port())
pv[jss::port] = *port;
}
else
pv[jss::ip] = sp->getRemoteAddress().to_string();
{
pv[jss::port] = std::to_string(
sp->getRemoteAddress().port());
}
}
auto version = sp->getVersion ();
if (!version.empty ())

View File

@@ -68,6 +68,8 @@ public:
/** The local endpoint of the socket, when known. */
virtual boost::optional <beast::IP::Endpoint> const& local_endpoint () const = 0;
virtual boost::optional<std::uint16_t> listening_port () const = 0;
/** The peer's public key, when known.
The public key is established when the handshake is complete.
*/

View File

@@ -262,6 +262,7 @@ public:
}
slot.canAccept = true;
slot.set_listening_port (checkedAddress.port ());
if (m_journal.debug) m_journal.debug << beast::leftw (18) <<
"Logic testing " << checkedAddress << " succeeded";
}

View File

@@ -35,6 +35,7 @@ SlotImp::SlotImp (beast::IP::Endpoint const& local_endpoint,
, m_state (accept)
, m_remote_endpoint (remote_endpoint)
, m_local_endpoint (local_endpoint)
, m_listening_port (unknownPort)
, checked (false)
, canAccept (false)
, connectivityCheckInProgress (false)
@@ -49,6 +50,7 @@ SlotImp::SlotImp (beast::IP::Endpoint const& remote_endpoint,
, m_cluster (false)
, m_state (connect)
, m_remote_endpoint (remote_endpoint)
, m_listening_port (unknownPort)
, checked (true)
, canAccept (true)
, connectivityCheckInProgress (false)

View File

@@ -22,9 +22,11 @@
#include <ripple/peerfinder/Slot.h>
#include <ripple/peerfinder/Manager.h>
#include <beast/config/CompilerConfig.h>
#include <beast/container/aged_unordered_map.h>
#include <beast/container/aged_container_utility.h>
#include <boost/optional.hpp>
#include <atomic>
namespace ripple {
namespace PeerFinder {
@@ -81,6 +83,19 @@ public:
return m_public_key;
}
boost::optional<std::uint16_t> listening_port () const
{
std::uint32_t const value = m_listening_port;
if (value == unknownPort)
return boost::none;
return value;
}
void set_listening_port (std::uint16_t port)
{
m_listening_port = port;
}
void local_endpoint (beast::IP::Endpoint const& endpoint)
{
m_local_endpoint = endpoint;
@@ -147,6 +162,9 @@ private:
boost::optional <beast::IP::Endpoint> m_local_endpoint;
boost::optional <RipplePublicKey> m_public_key;
static std::int32_t BEAST_CONSTEXPR unknownPort = -1;
std::atomic <std::int32_t> m_listening_port;
public:
// DEPRECATED public data members