prevent tor from spinning if a service is in a crash loop (#2316)

This commit is contained in:
Aiden McClelland
2023-06-22 12:09:59 -06:00
committed by GitHub
parent 95b3b55971
commit ef416ef60b

View File

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