diff --git a/src/net.h b/src/net.h --- a/src/net.h +++ b/src/net.h @@ -1326,6 +1326,8 @@ std::string GetAddrName() const; //! Sets the addrName only if it was not previously set void MaybeSetAddrName(const std::string &addrNameIn); + + std::string ConnectionTypeAsString() const; }; /** diff --git a/src/net.cpp b/src/net.cpp --- a/src/net.cpp +++ b/src/net.cpp @@ -515,6 +515,25 @@ } } +std::string CNode::ConnectionTypeAsString() const { + switch (m_conn_type) { + case ConnectionType::INBOUND: + return "inbound"; + case ConnectionType::MANUAL: + return "manual"; + case ConnectionType::FEELER: + return "feeler"; + case ConnectionType::OUTBOUND_FULL_RELAY: + return "outbound-full-relay"; + case ConnectionType::BLOCK_RELAY: + return "block-relay-only"; + case ConnectionType::ADDR_FETCH: + return "addr-fetch"; + } // no default case, so the compiler can warn about missing cases + + assert(false); +} + std::string CNode::GetAddrName() const { LOCK(cs_addrName); return addrName; diff --git a/src/net_processing.cpp b/src/net_processing.cpp --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -4481,15 +4481,8 @@ // the attack. if (!pfrom.IsInboundConn()) { LogPrint(BCLog::NET, - "Ignoring \"getaddr\" from outbound connection. peer=%d\n", - pfrom.GetId()); - return; - } - if (!pfrom.RelayAddrsWithConn()) { - LogPrint(BCLog::NET, - "Ignoring \"getaddr\" from block-relay-only connection. " - "peer=%d\n", - pfrom.GetId()); + "Ignoring \"getaddr\" from %s connection. peer=%d\n", + pfrom.ConnectionTypeAsString(), pfrom.GetId()); return; }