diff --git a/Cargo.lock b/Cargo.lock index 7093643..a170572 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -135,6 +135,12 @@ dependencies = [ "critical-section", ] +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + [[package]] name = "authenticator" version = "0.1.0" @@ -157,9 +163,9 @@ checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "axum" -version = "0.7.5" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a6c9af12842a67734c9a2e355436e5d03b22383ed60cf13cd0c18fbfe3dcbcf" +checksum = "8f43644eed690f5374f1af436ecd6aea01cd201f6fbdf0178adaf6907afb2cec" dependencies = [ "async-trait", "axum-core", @@ -184,7 +190,7 @@ dependencies = [ "serde_urlencoded", "sync_wrapper 1.0.1", "tokio", - "tower", + "tower 0.5.1", "tower-layer", "tower-service", "tracing", @@ -192,9 +198,9 @@ dependencies = [ [[package]] name = "axum-core" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a15c63fd72d41492dc4f497196f5da1fb04fb7529e631d73630d1b491e47a2e3" +checksum = "5e6b8ba012a258d63c9adfa28b9ddcf66149da6f986c5b5452e629d5ee64bf00" dependencies = [ "async-trait", "bytes", @@ -205,7 +211,7 @@ dependencies = [ "mime", "pin-project-lite", "rustversion", - "sync_wrapper 0.1.2", + "sync_wrapper 1.0.1", "tower-layer", "tower-service", "tracing", @@ -213,9 +219,9 @@ dependencies = [ [[package]] name = "axum-extra" -version = "0.9.3" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0be6ea09c9b96cb5076af0de2e383bd2bc0c18f827cf1967bdd353e0b910d733" +checksum = "73c3220b188aea709cf1b6c5f9b01c3bd936bb08bd2b5184a12b35ac8131b1f9" dependencies = [ "axum", "axum-core", @@ -230,7 +236,7 @@ dependencies = [ "serde", "tokio", "tokio-util", - "tower", + "tower 0.5.1", "tower-layer", "tower-service", "tracing", @@ -238,11 +244,10 @@ dependencies = [ [[package]] name = "axum-macros" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00c055ee2d014ae5981ce1016374e8213682aa14d9bf40e48ab48b5f3ef20eaa" +checksum = "57d123550fa8d071b7255cb0cc04dc302baa6c8c4a79f55701552684d8399bce" dependencies = [ - "heck 0.4.1", "proc-macro2", "quote", "syn", @@ -382,9 +387,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.17" +version = "4.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e5a21b8495e732f1b3c364c9949b201ca7bae518c502c80256c96ad79eaf6ac" +checksum = "b0956a43b323ac1afaffc053ed5c4b7c1f1800bacd1683c353aabbb752515dd3" dependencies = [ "clap_builder", "clap_derive", @@ -392,9 +397,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.17" +version = "4.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cf2dd12af7a047ad9d6da2b6b249759a22a7abc0f474c1dae1777afa4b21a73" +checksum = "4d72166dd41634086d5803a47eb71ae740e61d84709c36f3c34110173db3961b" dependencies = [ "anstream", "anstyle", @@ -404,11 +409,11 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.13" +version = "4.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "501d359d5f3dcaf6ecdeee48833ae73ec6e42723a1e52419c79abf9507eec0a0" +checksum = "4ac6a0c7b1a9e9a5186361f67dfa1b88213572f427fb9ab038efb2bd8c582dab" dependencies = [ - "heck 0.5.0", + "heck", "proc-macro2", "quote", "syn", @@ -472,6 +477,22 @@ dependencies = [ "url", ] +[[package]] +name = "core-foundation" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + [[package]] name = "cpufeatures" version = "0.2.14" @@ -683,12 +704,37 @@ version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "edd0f118536f44f5ccd48bcb8b111bdc3de888b58c74639dfb034a357d0f206d" +[[package]] +name = "encoding_rs" +version = "0.8.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59" +dependencies = [ + "cfg-if", +] + [[package]] name = "equivalent" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" +[[package]] +name = "errno" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "fastrand" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6" + [[package]] name = "fiat-crypto" version = "0.2.9" @@ -713,6 +759,21 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + [[package]] name = "form_urlencoded" version = "1.2.1" @@ -841,6 +902,25 @@ version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32085ea23f3234fc7846555e85283ba4de91e21016dc0455a16286d87a292d64" +[[package]] +name = "h2" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "524e8ac6999421f49a846c2d4411f337e53497d8ec55d67753beffa43c5d9205" +dependencies = [ + "atomic-waker", + "bytes", + "fnv", + "futures-core", + "futures-sink", + "http", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", +] + [[package]] name = "hash32" version = "0.2.1" @@ -894,12 +974,6 @@ dependencies = [ "stable_deref_trait", ] -[[package]] -name = "heck" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" - [[package]] name = "heck" version = "0.5.0" @@ -1011,6 +1085,7 @@ dependencies = [ "bytes", "futures-channel", "futures-util", + "h2", "http", "http-body", "httparse", @@ -1040,6 +1115,22 @@ dependencies = [ "webpki-roots", ] +[[package]] +name = "hyper-tls" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" +dependencies = [ + "bytes", + "http-body-util", + "hyper", + "hyper-util", + "native-tls", + "tokio", + "tokio-native-tls", + "tower-service", +] + [[package]] name = "hyper-util" version = "0.1.8" @@ -1054,7 +1145,7 @@ dependencies = [ "pin-project-lite", "socket2", "tokio", - "tower", + "tower 0.4.13", "tower-service", "tracing", ] @@ -1147,6 +1238,12 @@ dependencies = [ "libc", ] +[[package]] +name = "linux-raw-sys" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" + [[package]] name = "litrs" version = "0.4.1" @@ -1263,6 +1360,23 @@ dependencies = [ "getrandom", ] +[[package]] +name = "native-tls" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8614eb2c83d59d1c8cc974dd3f920198647674a0a035e1af1fa58707e317466" +dependencies = [ + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + [[package]] name = "nu-ansi-term" version = "0.46.0" @@ -1300,6 +1414,50 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" +[[package]] +name = "openssl" +version = "0.10.66" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9529f4786b70a3e8c61e11179af17ab6188ad8d0ded78c5529441ed39d4bd9c1" +dependencies = [ + "bitflags", + "cfg-if", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "openssl-probe" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" + +[[package]] +name = "openssl-sys" +version = "0.9.103" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f9e8deee91df40a943c71b917e5874b951d32a802526c85721ce3b776c929d6" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + [[package]] name = "overload" version = "0.1.1" @@ -1432,8 +1590,8 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pkarr" -version = "2.2.0" -source = "git+https://github.com/Pubky/pkarr?branch=v3#5b2f8e53735f63521b0d587167609a2cb9b8f2ab" +version = "3.0.0" +source = "git+https://github.com/Pubky/pkarr?branch=v3#d0be23324bcf706f5a359236d2945944abbb40f8" dependencies = [ "base32", "bytes", @@ -1442,18 +1600,17 @@ dependencies = [ "ed25519-dalek", "flume", "futures", + "getrandom", "js-sys", "lru", "mainline", "rand", + "reqwest", "self_cell", "serde", "simple-dns", "thiserror", "tracing", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", ] [[package]] @@ -1466,6 +1623,12 @@ dependencies = [ "spki", ] +[[package]] +name = "pkg-config" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" + [[package]] name = "poly1305" version = "0.8.0" @@ -1755,18 +1918,22 @@ dependencies = [ "bytes", "cookie", "cookie_store", + "encoding_rs", "futures-core", "futures-util", + "h2", "http", "http-body", "http-body-util", "hyper", "hyper-rustls", + "hyper-tls", "hyper-util", "ipnet", "js-sys", "log", "mime", + "native-tls", "once_cell", "percent-encoding", "pin-project-lite", @@ -1778,7 +1945,9 @@ dependencies = [ "serde_json", "serde_urlencoded", "sync_wrapper 1.0.1", + "system-configuration", "tokio", + "tokio-native-tls", "tokio-rustls", "tower-service", "url", @@ -1846,6 +2015,19 @@ dependencies = [ "semver", ] +[[package]] +name = "rustix" +version = "0.38.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8acb788b847c24f28525660c4d7758620a7210875711f79e7f663cc152726811" +dependencies = [ + "bitflags", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.52.0", +] + [[package]] name = "rustls" version = "0.23.13" @@ -1908,12 +2090,44 @@ dependencies = [ "cipher", ] +[[package]] +name = "schannel" +version = "0.1.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9aaafd5a2b6e3d657ff009d82fbd630b6bd54dd4eb06f21693925cdf80f9b8b" +dependencies = [ + "windows-sys 0.59.0", +] + [[package]] name = "scopeguard" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" +[[package]] +name = "security-framework" +version = "2.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" +dependencies = [ + "bitflags", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea4a292869320c0272d7bc55a5a6aafaff59b4f63404a003887b679a2e05b4b6" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "self_cell" version = "1.0.4" @@ -2181,6 +2395,40 @@ dependencies = [ "crossbeam-queue", ] +[[package]] +name = "system-configuration" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c879d448e9d986b661742763247d3693ed13609438cf3d006f51f5368a5ba6b" +dependencies = [ + "bitflags", + "core-foundation", + "system-configuration-sys", +] + +[[package]] +name = "system-configuration-sys" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e1d1b10ced5ca923a1fcb8d03e96b8d3268065d724548c0211415ff6ac6bac4" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "tempfile" +version = "3.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04cbcdd0c794ebb0d4cf35e88edd2f7d2c4c3e9a5a6dab322839b321c6a87a64" +dependencies = [ + "cfg-if", + "fastrand", + "once_cell", + "rustix", + "windows-sys 0.59.0", +] + [[package]] name = "thiserror" version = "1.0.63" @@ -2286,6 +2534,16 @@ dependencies = [ "syn", ] +[[package]] +name = "tokio-native-tls" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" +dependencies = [ + "native-tls", + "tokio", +] + [[package]] name = "tokio-rustls" version = "0.26.0" @@ -2357,6 +2615,21 @@ dependencies = [ "tokio", "tower-layer", "tower-service", +] + +[[package]] +name = "tower" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2873938d487c3cfb9aed7546dc9f2711d867c9f90c46b889989a2cb84eba6b4f" +dependencies = [ + "futures-core", + "futures-util", + "pin-project-lite", + "sync_wrapper 0.1.2", + "tokio", + "tower-layer", + "tower-service", "tracing", ] @@ -2540,6 +2813,12 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + [[package]] name = "version_check" version = "0.9.5" diff --git a/Cargo.toml b/Cargo.toml index d5a1fc7..03ee202 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ members = [ resolver = "2" [workspace.dependencies] -pkarr = { git = "https://github.com/Pubky/pkarr", branch = "v3", package = "pkarr", features = ["async"] } +pkarr = { git = "https://github.com/Pubky/pkarr", branch = "v3", package = "pkarr" } serde = { version = "^1.0.209", features = ["derive"] } [profile.release] diff --git a/pubky-homeserver/src/pkarr.rs b/pubky-homeserver/src/pkarr.rs index a4dac80..01cb56b 100644 --- a/pubky-homeserver/src/pkarr.rs +++ b/pubky-homeserver/src/pkarr.rs @@ -7,11 +7,11 @@ use pkarr::{ rdata::{RData, A, SVCB}, Packet, }, - Keypair, PkarrClientAsync, SignedPacket, + Keypair, SignedPacket, }; pub async fn publish_server_packet( - pkarr_client: PkarrClientAsync, + pkarr_client: pkarr::Client, keypair: &Keypair, domain: Option<&String>, port: u16, diff --git a/pubky-homeserver/src/server.rs b/pubky-homeserver/src/server.rs index 9558780..7866c32 100644 --- a/pubky-homeserver/src/server.rs +++ b/pubky-homeserver/src/server.rs @@ -7,7 +7,7 @@ use tracing::{debug, info, warn}; use pkarr::{ mainline::dht::{DhtSettings, Testnet}, - PkarrClient, PkarrClientAsync, PublicKey, Settings, + PublicKey, Settings, }; use crate::{config::Config, database::DB, pkarr::publish_server_packet}; @@ -23,7 +23,7 @@ pub struct Homeserver { pub(crate) struct AppState { pub verifier: AuthVerifier, pub db: DB, - pub pkarr_client: PkarrClientAsync, + pub pkarr_client: pkarr::Client, } impl Homeserver { @@ -34,15 +34,14 @@ impl Homeserver { let db = DB::open(&config.storage()?)?; - let pkarr_client = PkarrClient::new(Settings { + let pkarr_client = pkarr::Client::new(Settings { dht: DhtSettings { bootstrap: config.bootstsrap(), request_timeout: config.dht_request_timeout(), ..Default::default() }, ..Default::default() - })? - .as_async(); + })?; let state = AppState { verifier: AuthVerifier::default(), diff --git a/pubky/Cargo.toml b/pubky/Cargo.toml index 84f8bba..6905920 100644 --- a/pubky/Cargo.toml +++ b/pubky/Cargo.toml @@ -18,7 +18,7 @@ bytes = "^1.7.1" base64 = "0.22.1" pubky-common = { version = "0.1.0", path = "../pubky-common" } -pkarr = { workspace = true, features = ["async"] } +pkarr = { workspace = true } # Native dependencies [target.'cfg(not(target_arch = "wasm32"))'.dependencies] diff --git a/pubky/src/lib.rs b/pubky/src/lib.rs index 2b6cf42..9e22a3b 100644 --- a/pubky/src/lib.rs +++ b/pubky/src/lib.rs @@ -14,9 +14,6 @@ use std::{ use wasm_bindgen::prelude::*; -#[cfg(not(target_arch = "wasm32"))] -use ::pkarr::PkarrClientAsync; - pub use error::Error; #[cfg(not(target_arch = "wasm32"))] @@ -27,7 +24,7 @@ pub use crate::shared::list_builder::ListBuilder; pub struct PubkyClient { http: reqwest::Client, #[cfg(not(target_arch = "wasm32"))] - pub(crate) pkarr: PkarrClientAsync, + pub(crate) pkarr: pkarr::Client, /// A cookie jar for nodejs fetch. #[cfg(target_arch = "wasm32")] pub(crate) session_cookies: Arc>>, diff --git a/pubky/src/native.rs b/pubky/src/native.rs index e5406de..2aa8b9e 100644 --- a/pubky/src/native.rs +++ b/pubky/src/native.rs @@ -1,7 +1,7 @@ use std::time::Duration; use std::{net::ToSocketAddrs, sync::Arc}; -use ::pkarr::{mainline::dht::Testnet, PkarrClient}; +use ::pkarr::mainline::dht::Testnet; use crate::PubkyClient; @@ -54,7 +54,7 @@ impl PubkyClientBuilder { pub fn build(self) -> PubkyClient { // TODO: convert to Result - let pkarr = PkarrClient::new(self.pkarr_settings).unwrap().as_async(); + let pkarr = pkarr::Client::new(self.pkarr_settings).unwrap(); let dns_resolver: PkarrResolver = pkarr.clone().into(); PubkyClient { diff --git a/pubky/src/native/api/http.rs b/pubky/src/native/api/http.rs index ade2c8e..4d762b3 100644 --- a/pubky/src/native/api/http.rs +++ b/pubky/src/native/api/http.rs @@ -33,7 +33,7 @@ mod tests { let homeserver = Homeserver::start_test(&testnet).await.unwrap(); - let client = PubkyClient::testnet(); + let client = PubkyClient::builder().testnet(&testnet).build(); let url = format!("http://{}/", homeserver.public_key()); diff --git a/pubky/src/native/internals/resolver.rs b/pubky/src/native/internals/resolver.rs index ff2b2bb..b04ac09 100644 --- a/pubky/src/native/internals/resolver.rs +++ b/pubky/src/native/internals/resolver.rs @@ -1,6 +1,6 @@ use std::net::ToSocketAddrs; -use pkarr::{PkarrClientAsync, PublicKey}; +use pkarr::PublicKey; use reqwest::dns::{Addrs, Resolve}; use crate::error::{Error, Result}; @@ -11,12 +11,12 @@ const DEFAULT_MAX_CHAIN_LENGTH: u8 = 3; #[derive(Debug, Clone)] pub struct PkarrResolver { - pkarr: PkarrClientAsync, + pkarr: pkarr::Client, max_chain_length: u8, } impl PkarrResolver { - pub fn new(pkarr: PkarrClientAsync, max_chain_length: u8) -> Self { + pub fn new(pkarr: pkarr::Client, max_chain_length: u8) -> Self { PkarrResolver { pkarr, max_chain_length, @@ -90,14 +90,14 @@ impl Resolve for PkarrResolver { } } -impl From<&PkarrClientAsync> for PkarrResolver { - fn from(pkarr: &PkarrClientAsync) -> Self { +impl From<&pkarr::Client> for PkarrResolver { + fn from(pkarr: &pkarr::Client) -> Self { pkarr.clone().into() } } -impl From for PkarrResolver { - fn from(pkarr: PkarrClientAsync) -> Self { +impl From for PkarrResolver { + fn from(pkarr: pkarr::Client) -> Self { Self::new(pkarr, DEFAULT_MAX_CHAIN_LENGTH) } } @@ -107,14 +107,14 @@ mod tests { use super::*; use pkarr::dns::rdata::{A, SVCB}; use pkarr::dns::{self, rdata::RData}; + use pkarr::SignedPacket; use pkarr::{mainline::Testnet, Keypair}; - use pkarr::{PkarrClient, SignedPacket}; use std::future::Future; use std::pin::Pin; fn generate_subtree( - client: PkarrClientAsync, + client: pkarr::Client, depth: u8, branching: u8, domain: Option, @@ -169,7 +169,7 @@ mod tests { } fn generate( - client: PkarrClientAsync, + client: pkarr::Client, depth: u8, branching: u8, domain: Option, @@ -180,11 +180,7 @@ mod tests { #[tokio::test] async fn resolve_endpoints() { let testnet = Testnet::new(3); - let pkarr = PkarrClient::builder() - .testnet(&testnet) - .build() - .unwrap() - .as_async(); + let pkarr = pkarr::Client::builder().testnet(&testnet).build().unwrap(); let resolver: PkarrResolver = (&pkarr).into(); let tld = generate(pkarr, 3, 3, Some("example.com".to_string())).await; @@ -196,11 +192,7 @@ mod tests { #[tokio::test] async fn max_chain_exceeded() { let testnet = Testnet::new(3); - let pkarr = PkarrClient::builder() - .testnet(&testnet) - .build() - .unwrap() - .as_async(); + let pkarr = pkarr::Client::builder().testnet(&testnet).build().unwrap(); let resolver: PkarrResolver = (&pkarr).into(); @@ -220,11 +212,7 @@ mod tests { #[tokio::test] async fn resolve_addresses() { let testnet = Testnet::new(3); - let pkarr = PkarrClient::builder() - .testnet(&testnet) - .build() - .unwrap() - .as_async(); + let pkarr = pkarr::Client::builder().testnet(&testnet).build().unwrap(); let resolver: PkarrResolver = (&pkarr).into(); let tld = generate(pkarr, 3, 3, None).await; diff --git a/pubky/src/shared/pkarr.rs b/pubky/src/shared/pkarr.rs index 85055ef..b3027a5 100644 --- a/pubky/src/shared/pkarr.rs +++ b/pubky/src/shared/pkarr.rs @@ -185,8 +185,8 @@ mod tests { rdata::{HTTPS, SVCB}, Packet, }, - mainline::{dht::DhtSettings, Testnet}, - Keypair, PkarrClient, Settings, SignedPacket, + mainline::Testnet, + Keypair, SignedPacket, }; use pubky_homeserver::Homeserver; @@ -194,15 +194,7 @@ mod tests { async fn resolve_endpoint_https() { let testnet = Testnet::new(10); - let pkarr_client = PkarrClient::new(Settings { - dht: DhtSettings { - bootstrap: Some(testnet.bootstrap.clone()), - ..Default::default() - }, - ..Default::default() - }) - .unwrap() - .as_async(); + let pkarr_client = pkarr::Client::builder().testnet(&testnet).build().unwrap(); let domain = "example.com"; let mut target; @@ -285,15 +277,7 @@ mod tests { let server = Homeserver::start_test(&testnet).await.unwrap(); // Publish an intermediate controller of the homeserver - let pkarr_client = PkarrClient::new(Settings { - dht: DhtSettings { - bootstrap: Some(testnet.bootstrap.clone()), - ..Default::default() - }, - ..Default::default() - }) - .unwrap() - .as_async(); + let pkarr_client = pkarr::Client::builder().testnet(&testnet).build().unwrap(); let intermediate = Keypair::random();