hs: wait 360s for HsDir publish; floor cbtmintimeout at 10s
Some checks failed
ci / test (push) Failing after 6m21s
Some checks failed
ci / test (push) Failing after 6m21s
180s fail-closed cut a working descriptor upload while status was still Bootstrapping. Learned CBT can also drop to ~1s and kill HsDir circuits.
This commit is contained in:
parent
d4fb93c27e
commit
7701f61c71
4 changed files with 44 additions and 68 deletions
12
src/hs.rs
12
src/hs.rs
|
|
@ -12,6 +12,10 @@ use tor_hsservice::{HsNickname, OnionServiceConfig, RunningOnionService};
|
|||
use tor_rtcompat::PreferredRuntime;
|
||||
|
||||
pub const HS_PORT: u16 = 80;
|
||||
/// HsDir descriptor upload often stays Bootstrapping past 3 minutes.
|
||||
pub const PUBLISH_WAIT: Duration = Duration::from_secs(360);
|
||||
/// Consensus default `cbtmintimeout` is 10ms; learned CBT can drop to ~1s.
|
||||
pub const CBT_MIN_TIMEOUT_MS: i32 = 10_000;
|
||||
|
||||
pub type Client = Arc<TorClient<PreferredRuntime>>;
|
||||
|
||||
|
|
@ -20,6 +24,9 @@ pub fn client_config(state_dir: &std::path::Path, cache_dir: &std::path::Path) -
|
|||
std::fs::create_dir_all(cache_dir).expect("cache dir");
|
||||
let mut builder = TorClientConfigBuilder::from_directories(state_dir, cache_dir);
|
||||
builder.storage().permissions().dangerously_trust_everyone();
|
||||
builder
|
||||
.override_net_params()
|
||||
.insert("cbtmintimeout".to_string(), CBT_MIN_TIMEOUT_MS);
|
||||
builder.build().expect("TorClientConfig")
|
||||
}
|
||||
|
||||
|
|
@ -49,7 +56,7 @@ pub fn onion_string(svc: &RunningOnionService) -> Result<String, String> {
|
|||
}
|
||||
|
||||
pub async fn wait_until_published(svc: &RunningOnionService, label: &str) -> Result<(), String> {
|
||||
let deadline = Instant::now() + Duration::from_secs(180);
|
||||
let deadline = Instant::now() + PUBLISH_WAIT;
|
||||
let mut events = svc.status_events();
|
||||
loop {
|
||||
let st = svc.status();
|
||||
|
|
@ -66,7 +73,8 @@ pub async fn wait_until_published(svc: &RunningOnionService, label: &str) -> Res
|
|||
}
|
||||
if Instant::now() >= deadline {
|
||||
return Err(format!(
|
||||
"{label}: onion service did not publish within 180s: {:?}",
|
||||
"{label}: onion service did not publish within {}s: {:?}",
|
||||
PUBLISH_WAIT.as_secs(),
|
||||
st.state()
|
||||
));
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue