aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/net.cpp2
-rw-r--r--src/net.h9
-rw-r--r--src/rpc/net.cpp2
3 files changed, 13 insertions, 0 deletions
diff --git a/src/net.cpp b/src/net.cpp
index 15675a68ad..5b533d7d17 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -602,6 +602,8 @@ void CNode::copyStats(CNodeStats &stats, const std::vector<bool> &m_asmap)
// Leave string empty if addrLocal invalid (not filled in yet)
CService addrLocalUnlocked = GetAddrLocal();
stats.addrLocal = addrLocalUnlocked.IsValid() ? addrLocalUnlocked.ToString() : "";
+
+ stats.m_conn_type_string = ConnectionTypeAsString();
}
#undef X
diff --git a/src/net.h b/src/net.h
index 61a208802c..5e134ca7c8 100644
--- a/src/net.h
+++ b/src/net.h
@@ -114,6 +114,14 @@ struct CSerializedNetMsg
std::string m_type;
};
+const std::vector<std::string> CONNECTION_TYPE_DOC{
+ "outbound-full-relay (default automatic connections)",
+ "block-relay-only (does not relay transactions or addresses)",
+ "inbound (initiated by the peer)",
+ "manual (added via addnode RPC or -addnode/-connect configuration options)",
+ "addr-fetch (short-lived automatic connection for soliciting addresses)",
+ "feeler (short-lived automatic connection for testing addresses)"};
+
/** Different types of connections to a peer. This enum encapsulates the
* information we have available at the time of opening or accepting the
* connection. Aside from INBOUND, all types are initiated by us. */
@@ -692,6 +700,7 @@ public:
// Bind address of our side of the connection
CAddress addrBind;
uint32_t m_mapped_as;
+ std::string m_conn_type_string;
};
diff --git a/src/rpc/net.cpp b/src/rpc/net.cpp
index 5af4389857..e480bd2a40 100644
--- a/src/rpc/net.cpp
+++ b/src/rpc/net.cpp
@@ -113,6 +113,7 @@ static UniValue getpeerinfo(const JSONRPCRequest& request)
{RPCResult::Type::STR, "subver", "The string version"},
{RPCResult::Type::BOOL, "inbound", "Inbound (true) or Outbound (false)"},
{RPCResult::Type::BOOL, "addnode", "Whether connection was due to addnode/-connect or if it was an automatic/inbound connection"},
+ {RPCResult::Type::STR, "connection_type", "Type of connection: \n" + Join(CONNECTION_TYPE_DOC, ",\n") + "."},
{RPCResult::Type::NUM, "startingheight", "The starting height (block) of the peer"},
{RPCResult::Type::NUM, "banscore", "The ban score (DEPRECATED, returned only if config option -deprecatedrpc=banscore is passed)"},
{RPCResult::Type::NUM, "synced_headers", "The last header we have in common with this peer"},
@@ -228,6 +229,7 @@ static UniValue getpeerinfo(const JSONRPCRequest& request)
recvPerMsgCmd.pushKV(i.first, i.second);
}
obj.pushKV("bytesrecv_per_msg", recvPerMsgCmd);
+ obj.pushKV("connection_type", stats.m_conn_type_string);
ret.push_back(obj);
}