@@ -2474,6 +2474,7 @@ namespace nodetool
2474
2474
2475
2475
// fill response
2476
2476
const epee::net_utils::zone zone_type = context.m_remote_address .get_zone ();
2477
+ const bool is_public = (zone_type == epee::net_utils::zone::public_);
2477
2478
network_zone& zone = m_network_zones.at (zone_type);
2478
2479
2479
2480
// will add self to peerlist if in same zone as outgoing later in this function
@@ -2483,26 +2484,38 @@ namespace nodetool
2483
2484
std::vector<peerlist_entry> local_peerlist_new;
2484
2485
zone.m_peerlist .get_peerlist_head (local_peerlist_new, true , max_peerlist_size);
2485
2486
2487
+ /* Tor/I2P nodes receiving connections via forwarding (from tor/i2p daemon)
2488
+ do not know the address of the connecting peer. This is relayed to them,
2489
+ iff the node has setup an inbound hidden service. The other peer will have
2490
+ to use the random peer_id value to link the two. My initial thought is that
2491
+ the inbound peer should leave the other side marked as `<unknown tor host>`,
2492
+ etc., because someone could give faulty addresses over Tor/I2P to get the
2493
+ real peer with that identity banned/blacklisted.
2494
+
2495
+ \note Insert into `local_peerlist_new` so that it is only sent once like
2496
+ the other peers. */
2497
+ if (outgoing_to_same_zone)
2498
+ local_peerlist_new.push_back (
2499
+ peerlist_entry{zone.m_our_address , zone.m_config .m_peer_id , (is_public ? std::time (nullptr ) : 0 )}
2500
+ );
2501
+
2486
2502
// only include out peers we did not already send
2487
2503
rsp.local_peerlist_new .reserve (local_peerlist_new.size ());
2488
2504
for (auto &pe: local_peerlist_new)
2489
2505
{
2490
2506
if (!context.sent_addresses .insert (pe.adr ).second )
2491
2507
continue ;
2492
2508
rsp.local_peerlist_new .push_back (std::move (pe));
2509
+
2510
+ if (!is_public)
2511
+ rsp.local_peerlist_new .back ().last_seen = 0 ;
2493
2512
}
2494
2513
m_payload_handler.get_payload_sync_data (rsp.payload_data );
2495
2514
2496
- /* Tor/I2P nodes receiving connections via forwarding (from tor/i2p daemon)
2497
- do not know the address of the connecting peer. This is relayed to them,
2498
- iff the node has setup an inbound hidden service. The other peer will have
2499
- to use the random peer_id value to link the two. My initial thought is that
2500
- the inbound peer should leave the other side marked as `<unknown tor host>`,
2501
- etc., because someone could give faulty addresses over Tor/I2P to get the
2502
- real peer with that identity banned/blacklisted. */
2503
-
2504
- if (outgoing_to_same_zone)
2505
- rsp.local_peerlist_new .push_back (peerlist_entry{zone.m_our_address , zone.m_config .m_peer_id , std::time (nullptr )});
2515
+ // randomize so location of local inbound is not easily found
2516
+ std::shuffle (
2517
+ rsp.local_peerlist_new .begin (), rsp.local_peerlist_new .end (), crypto::random_device{}
2518
+ );
2506
2519
2507
2520
LOG_DEBUG_CC (context, " COMMAND_TIMED_SYNC" );
2508
2521
return 1 ;
0 commit comments