Merge pull request #5669

761a39a p2p: don't forget pruning seed or public RPC port when updating peers (moneromooo-monero)
This commit is contained in:
luigi1111 2019-07-01 00:15:39 -05:00
commit ae77f09e68
No known key found for this signature in database
GPG key ID: F4ACA0183641E010

View file

@ -345,7 +345,13 @@ namespace nodetool
}else }else
{ {
//update record in white list //update record in white list
m_peers_white.replace(by_addr_it_wt, ple); peerlist_entry new_ple = ple;
if (by_addr_it_wt->pruning_seed && ple.pruning_seed == 0) // guard against older nodes not passing pruning info around
new_ple.pruning_seed = by_addr_it_wt->pruning_seed;
if (by_addr_it_wt->rpc_port && ple.rpc_port == 0) // guard against older nodes not passing RPC port around
new_ple.rpc_port = by_addr_it_wt->rpc_port;
new_ple.last_seen = by_addr_it_wt->last_seen; // do not overwrite the last seen timestamp, incoming peer list are untrusted
m_peers_white.replace(by_addr_it_wt, new_ple);
} }
//remove from gray list, if need //remove from gray list, if need
auto by_addr_it_gr = m_peers_gray.get<by_addr>().find(ple.adr); auto by_addr_it_gr = m_peers_gray.get<by_addr>().find(ple.adr);
@ -379,8 +385,14 @@ namespace nodetool
trim_gray_peerlist(); trim_gray_peerlist();
}else }else
{ {
//update record in white list //update record in gray list
m_peers_gray.replace(by_addr_it_gr, ple); peerlist_entry new_ple = ple;
if (by_addr_it_gr->pruning_seed && ple.pruning_seed == 0) // guard against older nodes not passing pruning info around
new_ple.pruning_seed = by_addr_it_gr->pruning_seed;
if (by_addr_it_gr->rpc_port && ple.rpc_port == 0) // guard against older nodes not passing RPC port around
new_ple.rpc_port = by_addr_it_gr->rpc_port;
new_ple.last_seen = by_addr_it_gr->last_seen; // do not overwrite the last seen timestamp, incoming peer list are untrusted
m_peers_gray.replace(by_addr_it_gr, new_ple);
} }
return true; return true;
CATCH_ENTRY_L0("peerlist_manager::append_with_peer_gray()", false); CATCH_ENTRY_L0("peerlist_manager::append_with_peer_gray()", false);