@@ -1093,20 +1093,28 @@ static RPCHelpMan getaddrmaninfo()
1093
1093
};
1094
1094
}
1095
1095
1096
- UniValue AddrmanEntryToJSON (const AddrInfo& info)
1096
+ UniValue AddrmanEntryToJSON (const AddrInfo& info, CConnman& connman )
1097
1097
{
1098
1098
UniValue ret (UniValue::VOBJ);
1099
1099
ret.pushKV (" address" , info.ToStringAddr ());
1100
+ const auto mapped_as{connman.GetMappedAS (info)};
1101
+ if (mapped_as != 0 ) {
1102
+ ret.pushKV (" mapped_as" , mapped_as);
1103
+ }
1100
1104
ret.pushKV (" port" , info.GetPort ());
1101
1105
ret.pushKV (" services" , (uint64_t )info.nServices );
1102
1106
ret.pushKV (" time" , int64_t {TicksSinceEpoch<std::chrono::seconds>(info.nTime )});
1103
1107
ret.pushKV (" network" , GetNetworkName (info.GetNetClass ()));
1104
1108
ret.pushKV (" source" , info.source .ToStringAddr ());
1105
1109
ret.pushKV (" source_network" , GetNetworkName (info.source .GetNetClass ()));
1110
+ const auto source_mapped_as{connman.GetMappedAS (info.source )};
1111
+ if (source_mapped_as != 0 ) {
1112
+ ret.pushKV (" source_mapped_as" , source_mapped_as);
1113
+ }
1106
1114
return ret;
1107
1115
}
1108
1116
1109
- UniValue AddrmanTableToJSON (const std::vector<std::pair<AddrInfo, AddressPosition>>& tableInfos)
1117
+ UniValue AddrmanTableToJSON (const std::vector<std::pair<AddrInfo, AddressPosition>>& tableInfos, CConnman& connman )
1110
1118
{
1111
1119
UniValue table (UniValue::VOBJ);
1112
1120
for (const auto & e : tableInfos) {
@@ -1117,7 +1125,7 @@ UniValue AddrmanTableToJSON(const std::vector<std::pair<AddrInfo, AddressPositio
1117
1125
// Address manager tables have unique entries so there is no advantage
1118
1126
// in using UniValue::pushKV, which checks if the key already exists
1119
1127
// in O(N). UniValue::pushKVEnd is used instead which currently is O(1).
1120
- table.pushKVEnd (key.str (), AddrmanEntryToJSON (info));
1128
+ table.pushKVEnd (key.str (), AddrmanEntryToJSON (info, connman ));
1121
1129
}
1122
1130
return table;
1123
1131
}
@@ -1133,12 +1141,14 @@ static RPCHelpMan getrawaddrman()
1133
1141
{RPCResult::Type::OBJ_DYN, " table" , " buckets with addresses in the address manager table ( new, tried )" , {
1134
1142
{RPCResult::Type::OBJ, " bucket/position" , " the location in the address manager table (<bucket>/<position>)" , {
1135
1143
{RPCResult::Type::STR, " address" , " The address of the node" },
1144
+ {RPCResult::Type::NUM, " mapped_as" , /* optional=*/ true , " The ASN mapped to the IP of this peer per our current ASMap" },
1136
1145
{RPCResult::Type::NUM, " port" , " The port number of the node" },
1137
1146
{RPCResult::Type::STR, " network" , " The network (" + Join (GetNetworkNames (), " , " ) + " ) of the address" },
1138
1147
{RPCResult::Type::NUM, " services" , " The services offered by the node" },
1139
1148
{RPCResult::Type::NUM_TIME, " time" , " The " + UNIX_EPOCH_TIME + " when the node was last seen" },
1140
1149
{RPCResult::Type::STR, " source" , " The address that relayed the address to us" },
1141
1150
{RPCResult::Type::STR, " source_network" , " The network (" + Join (GetNetworkNames (), " , " ) + " ) of the source address" },
1151
+ {RPCResult::Type::NUM, " source_mapped_as" , /* optional=*/ true , " The ASN mapped to the IP of this peer's source per our current ASMap" }
1142
1152
}}
1143
1153
}}
1144
1154
}
@@ -1149,10 +1159,12 @@ static RPCHelpMan getrawaddrman()
1149
1159
},
1150
1160
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue {
1151
1161
AddrMan& addrman = EnsureAnyAddrman (request.context );
1162
+ NodeContext& node_context = EnsureAnyNodeContext (request.context );
1163
+ CConnman& connman = EnsureConnman (node_context);
1152
1164
1153
1165
UniValue ret (UniValue::VOBJ);
1154
- ret.pushKV (" new" , AddrmanTableToJSON (addrman.GetEntries (false )));
1155
- ret.pushKV (" tried" , AddrmanTableToJSON (addrman.GetEntries (true )));
1166
+ ret.pushKV (" new" , AddrmanTableToJSON (addrman.GetEntries (false ), connman ));
1167
+ ret.pushKV (" tried" , AddrmanTableToJSON (addrman.GetEntries (true ), connman ));
1156
1168
return ret;
1157
1169
},
1158
1170
};
0 commit comments