Skip to content

Commit

Permalink
fix(iroh-net): staging url for pkarr publish
Browse files Browse the repository at this point in the history
  • Loading branch information
Frando committed Jul 5, 2024
1 parent f4d1e71 commit 2fcb091
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions iroh-net/src/discovery/pkarr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ use crate::{
AddrInfo, Endpoint, NodeId,
};

/// The pkarr relay run by n0.
pub const N0_DNS_PKARR_RELAY: &str = "https://dns.iroh.link/pkarr";
/// The pkarr relay run by n0, for production.
pub const N0_DNS_PKARR_RELAY_PROD: &str = "https://dns.iroh.link/pkarr";
/// The pkarr relay run by n0, for testing.
pub const N0_DNS_PKARR_RELAY_STAGING: &str = "https://staging-dns.iroh.link/pkarr";

/// Default TTL for the records in the pkarr signed packet. TTL tells DNS caches
/// how long to store a record. It is ignored by the iroh-dns-server as the home
Expand Down Expand Up @@ -67,6 +69,7 @@ impl PkarrPublisher {
ttl: u32,
republish_interval: std::time::Duration,
) -> Self {
debug!("creating pkarr publisher that publishes to {pkarr_relay}");
let node_id = secret_key.public();
let pkarr_client = PkarrRelayClient::new(pkarr_relay);
let watchable = Watchable::default();
Expand All @@ -89,9 +92,15 @@ impl PkarrPublisher {
}
}

/// Create a config that publishes to the n0 dns server through [`N0_DNS_PKARR_RELAY`].
/// Create a pkarr publisher which uses the [`N0_DNS_PKARR_RELAY_PROD`] pkarr relay and in testing
/// uses [`N0_DNS_PKARR_RELAY_STAGING`].
pub fn n0_dns(secret_key: SecretKey) -> Self {
let pkarr_relay: Url = N0_DNS_PKARR_RELAY.parse().expect("url is valid");
#[cfg(not(any(test, feature = "test-utils")))]
let pkarr_relay = N0_DNS_PKARR_RELAY_PROD;
#[cfg(any(test, feature = "test-utils"))]
let pkarr_relay = N0_DNS_PKARR_RELAY_STAGING;

let pkarr_relay: Url = pkarr_relay.parse().expect("url is valid");
Self::new(secret_key, pkarr_relay)
}

Expand Down Expand Up @@ -205,7 +214,7 @@ impl PkarrResolver {

/// Create a config that resolves using the n0 dns server through [`N0_DNS_PKARR_RELAY`].
pub fn n0_dns() -> Self {
let pkarr_relay: Url = N0_DNS_PKARR_RELAY.parse().expect("url is valid");
let pkarr_relay: Url = N0_DNS_PKARR_RELAY_PROD.parse().expect("url is valid");
Self::new(pkarr_relay)
}
}
Expand Down

0 comments on commit 2fcb091

Please sign in to comment.