status shows each home relay: connected, down with the error, or denied

iroh 1.3's home_relay_status, on GlobalStatus as relays (absent when
empty, so older clients parse it). The thing we lacked when fetches
timed out: whether this daemon can be reached through a relay at all.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
Bendik Aagaard Lynghaug
2026-10-03 14:08:41 +02:00
co-authored by Claude Fable 5.1
parent 7916e59acb
commit 7322812524
4 changed files with 57 additions and 1 deletions
+1
View File
@@ -486,6 +486,7 @@ impl Daemon {
store_path: self.config.store_dir.display().to_string(),
pins: self.meta.pins().len() as u64,
connected_peers: connected,
relays: self.transfer.relay_status(),
}))
}
Request::Status { hash: Some(hash) } => {
+17 -1
View File
@@ -12,7 +12,7 @@ use std::time::Duration;
use anyhow::{Context, Result};
use iroh::address_lookup::memory::MemoryLookup;
use iroh::protocol::Router;
use iroh::{Endpoint, EndpointAddr, EndpointId, RelayMode, SecretKey};
use iroh::{Endpoint, EndpointAddr, EndpointId, RelayMode, SecretKey, Watcher as _};
use iroh_blobs::api::downloader::{DownloadOptions, Downloader, Shuffled, SplitStrategy};
use iroh_blobs::protocol::GetRequest;
use iroh_blobs::{BlobFormat, BlobsProtocol, Hash, HashAndFormat};
@@ -156,6 +156,22 @@ impl Transfer {
self.endpoint.id().to_string()
}
/// How each home relay is doing right now: connected, or why not.
/// Empty with relays disabled.
pub fn relay_status(&self) -> Vec<varde_proto::RelayInfo> {
self.endpoint
.home_relay_status()
.get()
.iter()
.map(|r| varde_proto::RelayInfo {
url: r.url().to_string(),
connected: r.is_connected(),
last_error: r.last_error().map(|e| format!("{e:#}")),
auth_denied: r.auth_denied_reason().map(str::to_string),
})
.collect()
}
/// The endpoint's identity key (also signs our announcements).
pub fn secret_key(&self) -> SecretKey {
self.endpoint.secret_key().clone()