@@ -315,6 +315,20 @@ class NetinfoRequestHandler : public BaseRequestHandler
315
315
(onion_pos == addr_len - ONION_LEN || onion_pos == addr.find_last_of (" :" ) - ONION_LEN);
316
316
}
317
317
bool m_verbose{false }; // !< Whether user requested verbose -netinfo report
318
+ enum struct NetType {
319
+ ipv4,
320
+ ipv6,
321
+ onion,
322
+ };
323
+ std::string NetTypeEnumToString (NetType t)
324
+ {
325
+ switch (t) {
326
+ case NetType::ipv4: return " ipv4" ;
327
+ case NetType::ipv6: return " ipv6" ;
328
+ case NetType::onion: return " onion" ;
329
+ } // no default case, so the compiler can warn about missing cases
330
+ assert (false );
331
+ }
318
332
std::string ChainToString () const
319
333
{
320
334
if (gArgs .GetChainName () == CBaseChainParams::TESTNET) return " testnet" ;
@@ -354,19 +368,24 @@ class NetinfoRequestHandler : public BaseRequestHandler
354
368
const int mapped_as{peer[" mapped_as" ].isNull () ? 0 : peer[" mapped_as" ].get_int ()};
355
369
const bool is_block_relay{!peer[" relaytxes" ].get_bool ()};
356
370
const bool is_inbound{peer[" inbound" ].get_bool ()};
371
+ NetType net_type{NetType::ipv4};
357
372
if (is_inbound) {
358
373
if (IsAddrIPv6 (addr)) {
374
+ net_type = NetType::ipv6;
359
375
++ipv6_i;
360
376
} else if (IsInboundOnion (addr_local, mapped_as)) {
377
+ net_type = NetType::onion;
361
378
++onion_i;
362
379
} else {
363
380
++ipv4_i;
364
381
}
365
382
if (is_block_relay) ++block_relay_i;
366
383
} else {
367
384
if (IsAddrIPv6 (addr)) {
385
+ net_type = NetType::ipv6;
368
386
++ipv6_o;
369
387
} else if (IsOutboundOnion (addr, mapped_as)) {
388
+ net_type = NetType::onion;
370
389
++onion_o;
371
390
} else {
372
391
++ipv4_o;
0 commit comments