Skip to content

deps!: update pkarr to v3 #3186

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 22 commits into from
Apr 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 73 additions & 51 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions iroh-dns-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ humantime-serde = "1.1.1"
iroh-metrics = { version = "0.32.0", features = ["metrics", "service"] }
lru = "0.12.3"
n0-future = "0.1.2"
pkarr = { version = "2.3.1", features = [ "async", "relay", "dht"], default-features = false }
pkarr = { version = "3.7", features = ["relays", "dht"], default-features = false }
rcgen = "0.13"
redb = "2.0.0"
regex = "1.10.3"
Expand Down Expand Up @@ -61,7 +61,6 @@ z32 = "1.1.1"
criterion = "0.5.1"
hickory-resolver = "0.25.0"
iroh = { path = "../iroh" }
pkarr = { version = "2.3.1", features = ["rand"] }
rand = "0.8"
rand_chacha = "0.3.1"
testresult = "0.4.1"
Expand Down
29 changes: 12 additions & 17 deletions iroh-dns-server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ mod tests {
discovery::pkarr::PkarrRelayClient, dns::DnsResolver, node_info::NodeInfo, RelayUrl,
SecretKey,
};
use pkarr::{PkarrClient, SignedPacket};
use pkarr::{SignedPacket, Timestamp};
use testresult::TestResult;
use tracing_test::traced_test;

Expand Down Expand Up @@ -101,13 +101,13 @@ mod tests {
30,
dns::rdata::RData::AAAA(Ipv6Addr::LOCALHOST.into()),
));
SignedPacket::from_packet(&keypair, &packet)?
SignedPacket::new(&keypair, &packet.answers, Timestamp::now())?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not important here, but if there are other places where you have similar verbosity, reminder that the new SignedPacket::builder() api is much nicer.

};
let pkarr_client = pkarr::PkarrRelayClient::new(pkarr::RelaySettings {
relays: vec![pkarr_relay_url.to_string()],
..Default::default()
})?;
pkarr_client.as_async().publish(&signed_packet).await?;
let pkarr_client = pkarr::Client::builder()
.no_default_network()
.relays(&[pkarr_relay_url])?
.build()?;
pkarr_client.publish(&signed_packet, None).await?;

use hickory_server::proto::rr::Name;
let pubkey = signed_packet.public_key().to_z32();
Expand Down Expand Up @@ -219,7 +219,7 @@ mod tests {
#[traced_test]
async fn integration_mainline() -> Result<()> {
// run a mainline testnet
let testnet = pkarr::mainline::dht::Testnet::new(5);
let testnet = pkarr::mainline::Testnet::new_async(5).await?;
let bootstrap = testnet.bootstrap.clone();

// spawn our server with mainline support
Expand All @@ -237,13 +237,11 @@ mod tests {
let signed_packet = node_info.to_pkarr_signed_packet(&secret_key, 30)?;

// publish the signed packet to our DHT
let pkarr = PkarrClient::builder()
.dht_settings(pkarr::mainline::dht::DhtSettings {
bootstrap: Some(testnet.bootstrap),
..Default::default()
})
let pkarr = pkarr::Client::builder()
.no_default_network()
.dht(|builder| builder.bootstrap(&testnet.bootstrap))
.build()?;
pkarr.publish(&signed_packet)?;
pkarr.publish(&signed_packet, None).await?;

// resolve via DNS from our server, which will lookup from our DHT
let resolver = test_resolver(nameserver);
Expand All @@ -253,9 +251,6 @@ mod tests {
assert_eq!(res.relay_url(), Some(&relay_url));

server.shutdown().await?;
for mut node in testnet.nodes {
node.shutdown()?;
}
Ok(())
}

Expand Down
15 changes: 6 additions & 9 deletions iroh-dns-server/src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use anyhow::Result;
use hickory_server::proto::rr::{Name, RecordSet, RecordType, RrKey};
use iroh_metrics::inc;
use lru::LruCache;
use pkarr::{mainline::dht::DhtSettings, PkarrClient, SignedPacket};
use pkarr::{Client as PkarrClient, SignedPacket};
use tokio::sync::Mutex;
use tracing::{debug, trace};
use ttl_cache::TtlCache;
Expand Down Expand Up @@ -66,10 +66,7 @@ impl ZoneStore {
let pkarr_client = match bootstrap {
BootstrapOption::Default => PkarrClient::builder().build().unwrap(),
BootstrapOption::Custom(bootstrap) => PkarrClient::builder()
.dht_settings(DhtSettings {
bootstrap: Some(bootstrap),
..Default::default()
})
.dht(|builder| builder.bootstrap(&bootstrap))
.build()
.unwrap(),
};
Expand Down Expand Up @@ -116,9 +113,9 @@ impl ZoneStore {
//
// it will be cached for some time.
debug!("DHT resolve {}", key.to_z32());
let packet_opt = pkarr.as_ref().clone().as_async().resolve(&key).await?;
let packet_opt = pkarr.resolve(&key).await;
if let Some(packet) = packet_opt {
debug!("DHT resolve successful {:?}", packet.packet());
debug!("DHT resolve successful {:?}", packet);
return self
.cache
.lock()
Expand Down Expand Up @@ -249,12 +246,12 @@ impl CachedZone {
signed_packet_to_hickory_records_without_origin(signed_packet, |_| true)?;
Ok(Self {
records,
timestamp: signed_packet.timestamp(),
timestamp: signed_packet.timestamp().into(),
})
}

fn is_newer_than(&self, signed_packet: &SignedPacket) -> bool {
self.timestamp > signed_packet.timestamp()
self.timestamp > signed_packet.timestamp().into()
}

fn resolve(&self, name: &Name, record_type: RecordType) -> Option<Arc<RecordSet>> {
Expand Down
Loading
Loading