Skip to content

Commit

Permalink
support work over proxy HTTP/HTTPS/SOCKS (dtn7#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
вашÐiwojim0 committed Jan 28, 2024
1 parent 4a6e4cc commit 8a0ae0d
Showing 1 changed file with 18 additions and 20 deletions.
38 changes: 18 additions & 20 deletions core/dtn7/src/cla/httppull.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::collections::HashMap;
use std::convert::TryFrom;
use std::net::IpAddr;

use crate::core::helpers::get_complete_digest;
use crate::core::peer::PeerAddress;
Expand All @@ -23,7 +22,7 @@ pub struct HttpPullConvergenceLayer {

async fn http_pull_from_node(
eid: EndpointID,
addr: IpAddr,
addr: PeerAddress,
port: u16,
local_digest: String,
) -> TransferResult {
Expand All @@ -46,7 +45,8 @@ 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 {
Expand Down Expand Up @@ -124,25 +124,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, port, local_digest).await;
});
} else {
http_pull_from_node(peer.eid, ipaddr, port, local_digest).await;
}
}
if CONFIG.lock().parallel_bundle_processing {
tokio::spawn(async move {
http_pull_from_node(peer.eid, peer.addr, port, local_digest).await;
});
} else {
http_pull_from_node(peer.eid, peer.addr, port, local_digest).await;
}
}
debug!("finished pulling bundles from peers");
Expand Down

0 comments on commit 8a0ae0d

Please sign in to comment.