Skip to content

Commit

Permalink
prevent tor from spinning if a service is in a crash loop (#2316)
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-bonez authored Jun 22, 2023
1 parent 95b3b55 commit ef416ef
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions backend/src/net/tor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,8 +416,8 @@ async fn torctl(
)
.await?;

for (key, service) in &*services {
let key = TorSecretKeyV3::from(*key);
for (key, service) in std::mem::take(services) {
let key = TorSecretKeyV3::from(key);
let bindings = service
.iter()
.flat_map(|(ext, int)| {
Expand All @@ -426,9 +426,12 @@ async fn torctl(
.map(|(addr, _)| (*ext, SocketAddr::from(*addr)))
})
.collect::<Vec<_>>();
connection
.add_onion_v3(&key, false, false, false, None, &mut bindings.iter())
.await?;
if !bindings.is_empty() {
services.insert(key.as_bytes(), service);
connection
.add_onion_v3(&key, false, false, false, None, &mut bindings.iter())
.await?;
}
}

let handler = async {
Expand Down

0 comments on commit ef416ef

Please sign in to comment.