mirror of
https://github.com/0glabs/0g-storage-node.git
synced 2024-12-24 07:15:17 +00:00
Do not verify announced ip address by default (#163)
Some checks failed
abi-consistent-check / build-and-compare (push) Has been cancelled
code-coverage / unittest-cov (push) Has been cancelled
rust / check (push) Has been cancelled
rust / test (push) Has been cancelled
rust / lints (push) Has been cancelled
functional-test / test (push) Has been cancelled
Some checks failed
abi-consistent-check / build-and-compare (push) Has been cancelled
code-coverage / unittest-cov (push) Has been cancelled
rust / check (push) Has been cancelled
rust / test (push) Has been cancelled
rust / lints (push) Has been cancelled
functional-test / test (push) Has been cancelled
This commit is contained in:
parent
c337ff90fb
commit
c1f465e009
@ -24,6 +24,7 @@ pub struct Config {
|
||||
pub max_idle_outgoing_peers: usize,
|
||||
pub libp2p_nodes: Vec<Multiaddr>,
|
||||
pub private_ip_enabled: bool,
|
||||
pub check_announced_ip: bool,
|
||||
}
|
||||
|
||||
impl Default for Config {
|
||||
@ -35,6 +36,7 @@ impl Default for Config {
|
||||
max_idle_outgoing_peers: 20,
|
||||
libp2p_nodes: vec![],
|
||||
private_ip_enabled: false,
|
||||
check_announced_ip: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -447,7 +447,7 @@ impl Libp2pEventHandler {
|
||||
if matches!(self.store.check_tx_completed(tx_id.seq).await, Ok(true)) {
|
||||
if let Ok(Some(tx)) = self.store.get_tx_by_seq_number(tx_id.seq).await {
|
||||
if tx.id() == tx_id {
|
||||
debug!(?tx_id, "Found file locally, responding to FindFile query");
|
||||
trace!(?tx_id, "Found file locally, responding to FindFile query");
|
||||
|
||||
return match self.construct_announce_file_message(tx_id).await {
|
||||
Some(msg) => {
|
||||
@ -463,7 +463,7 @@ impl Libp2pEventHandler {
|
||||
|
||||
// try from cache
|
||||
if let Some(mut msg) = self.file_location_cache.get_one(tx_id) {
|
||||
debug!(?tx_id, "Found file in cache, responding to FindFile query");
|
||||
trace!(?tx_id, "Found file in cache, responding to FindFile query");
|
||||
|
||||
msg.resend_timestamp = timestamp_now();
|
||||
self.publish(PubsubMessage::AnnounceFile(msg));
|
||||
@ -520,7 +520,7 @@ impl Libp2pEventHandler {
|
||||
metrics::LIBP2P_HANDLE_PUBSUB_LATENCY_FIND_CHUNKS.clone(),
|
||||
);
|
||||
if d < TOLERABLE_DRIFT.neg() || d > *FIND_FILE_TIMEOUT {
|
||||
debug!(%msg.timestamp, ?d, "Invalid timestamp, ignoring FindFile message");
|
||||
debug!(%msg.timestamp, ?d, "Invalid timestamp, ignoring FindChunks message");
|
||||
return MessageAcceptance::Ignore;
|
||||
}
|
||||
|
||||
@ -554,7 +554,7 @@ impl Libp2pEventHandler {
|
||||
_ => return MessageAcceptance::Accept,
|
||||
};
|
||||
|
||||
debug!(?msg, "Found chunks to respond FindChunks message");
|
||||
trace!(?msg, "Found chunks to respond FindChunks message");
|
||||
|
||||
match self
|
||||
.construct_announce_chunks_message(msg.tx_id, msg.index_start, msg.index_end)
|
||||
@ -625,7 +625,10 @@ impl Libp2pEventHandler {
|
||||
}
|
||||
|
||||
// verify announced ip address if required
|
||||
if !self.config.private_ip_enabled && !self.verify_announced_address(&msg.peer_id, &addr) {
|
||||
if !self.config.private_ip_enabled
|
||||
&& self.config.check_announced_ip
|
||||
&& !self.verify_announced_address(&msg.peer_id, &addr)
|
||||
{
|
||||
return MessageAcceptance::Reject;
|
||||
}
|
||||
|
||||
@ -669,7 +672,10 @@ impl Libp2pEventHandler {
|
||||
}
|
||||
|
||||
// verify announced ip address if required
|
||||
if !self.config.private_ip_enabled && !self.verify_announced_address(&msg.peer_id, &addr) {
|
||||
if !self.config.private_ip_enabled
|
||||
&& self.config.check_announced_ip
|
||||
&& !self.verify_announced_address(&msg.peer_id, &addr)
|
||||
{
|
||||
return MessageAcceptance::Reject;
|
||||
}
|
||||
|
||||
@ -718,7 +724,10 @@ impl Libp2pEventHandler {
|
||||
}
|
||||
|
||||
// verify announced ip address if required
|
||||
if !self.config.private_ip_enabled && !self.verify_announced_address(&msg.peer_id, &addr) {
|
||||
if !self.config.private_ip_enabled
|
||||
&& self.config.check_announced_ip
|
||||
&& !self.verify_announced_address(&msg.peer_id, &addr)
|
||||
{
|
||||
return MessageAcceptance::Reject;
|
||||
}
|
||||
|
||||
|
@ -263,7 +263,7 @@ impl RouterService {
|
||||
break;
|
||||
}
|
||||
Err(err) => {
|
||||
debug!(address = %multiaddr, error = ?err, "Could not connect to peer")
|
||||
debug!(address = %multiaddr, error = ?err, "Could not connect to peer");
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -385,8 +385,11 @@ impl RouterService {
|
||||
async fn on_heartbeat(&mut self) {
|
||||
let expired_peers = self.peers.write().await.expired_peers();
|
||||
|
||||
metrics::SERVICE_EXPIRED_PEERS.update(expired_peers.len() as u64);
|
||||
trace!("heartbeat, expired peers = {:?}", expired_peers.len());
|
||||
let num_expired_peers = expired_peers.len() as u64;
|
||||
metrics::SERVICE_EXPIRED_PEERS.update(num_expired_peers);
|
||||
if num_expired_peers > 0 {
|
||||
debug!(%num_expired_peers, "Heartbeat, remove expired peers")
|
||||
}
|
||||
|
||||
let mut num_succeeded = 0;
|
||||
let mut num_failed = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user