From eb672bc83dbb48a90e548757212e546f661d1ddb Mon Sep 17 00:00:00 2001 From: iwojim0 Date: Sat, 9 Mar 2024 12:52:33 +0000 Subject: [PATCH] support work over proxy HTTP/HTTPS/SOCKS (https://github.com/dtn7/dtn7-rs/issues/52) --- core/dtn7/src/cla/httppull.rs | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/core/dtn7/src/cla/httppull.rs b/core/dtn7/src/cla/httppull.rs index 6a62c2b9..10c59781 100644 --- a/core/dtn7/src/cla/httppull.rs +++ b/core/dtn7/src/cla/httppull.rs @@ -2,7 +2,6 @@ use std::collections::HashMap; use std::convert::TryFrom; use crate::core::helpers::get_complete_digest; -use crate::core::peer::PeerAddress; use crate::{store_has_item, CONFIG}; use super::TransferResult; @@ -44,7 +43,7 @@ async fn http_pull_from_node( return TransferResult::Failure; } }; - if digest == local_digest { + if digest == local_digest || digest.len() != 40 { debug!("no new bundles on remote"); return TransferResult::Successful; } else { @@ -121,25 +120,23 @@ async fn http_pull_bundles() { let peers = crate::PEERS.lock().clone(); for (_, p) in peers.iter() { - if let PeerAddress::Ip(ipaddr) = p.addr { - let peer = p.clone(); - let local_digest = local_digest.clone(); - let mut port = 3000; - for cla in p.cla_list.iter() { - if cla.0 == "httppull" { - if let Some(p) = cla.1 { - port = p; - break; - } + let peer = p.clone(); + let local_digest = local_digest.clone(); + let mut port = 3000; + for cla in p.cla_list.iter() { + if cla.0 == "httppull" { + if let Some(p) = cla.1 { + port = p; + break; } } - if CONFIG.lock().parallel_bundle_processing { - tokio::spawn(async move { - http_pull_from_node(peer.eid, ipaddr.to_string(), port, local_digest).await; - }); - } else { - http_pull_from_node(peer.eid, ipaddr.to_string(), port, local_digest).await; - } + } + if CONFIG.lock().parallel_bundle_processing { + tokio::spawn(async move { + http_pull_from_node(peer.eid, peer.addr.to_string(), port, local_digest).await; + }); + } else { + http_pull_from_node(peer.eid, peer.addr.to_string(), port, local_digest).await; } } debug!("finished pulling bundles from peers");