Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
20 changes: 19 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ mdns = ["libp2p/mdns"]

keypair_base64_encoding = ["dep:base64"]

dns = ["libp2p/dns"]
dns = ["libp2p/dns", "dep:parking_lot", "dep:serde", "dep:serde_json", "dep:url", "dep:js-sys", "dep:web-sys"]
tls = ["libp2p/tls"]
noise = ["libp2p/noise"]
tcp = ["libp2p/tcp"]
Expand Down Expand Up @@ -91,6 +91,7 @@ libp2p-webrtc = { version = "=0.9.0-alpha.1", features = ["pem"] }
libp2p-webrtc-websys = "0.4.0"
other-error = "0.1.1"
pollable-map = "0.1.7"
parking_lot = "0.12"
pem = { version = "3.0.5" }
cbor4ii = { version = "1.2.2", features = ["serde1"] }
rand = "0.8.5"
Expand All @@ -102,14 +103,26 @@ send_wrapper = "0.6.0"
serde = { version = "1.0.219" }
serde-wasm-bindgen = "0.6.5"
serde_bytes = "0.11.19"
serde_json = "1"
sqlx = { version = "0.8", default-features = false, features = ["runtime-tokio", "sqlite"] }
thiserror = "2.0.18"
tracing = { version = "0.1.41" }
zeroize = "1.8.1"

tokio = { default-features = false, version = "1.47.1" }
js-sys = "0.3"
url = "2"
wasm-bindgen = "0.2"
wasm-bindgen-futures = { version = "0.4.50" }
web-sys = { version = "0.3", features = [
"AbortSignal",
"Headers",
"Request",
"RequestInit",
"Response",
"Window",
"WorkerGlobalScope",
] }
web-time = "1.1.0"


Expand Down Expand Up @@ -156,10 +169,15 @@ futures-timer = { workspace = true, features = ["wasm-bindgen"] }
getrandom = { workspace = true, features = ["js"] }
getrandom_03 = { workspace = true, features = ["wasm_js"] }
idb = { workspace = true, optional = true }
js-sys = { workspace = true, optional = true }
libp2p = { features = ["macros", "serde", "wasm-bindgen"], workspace = true }
libp2p-webrtc-websys = { workspace = true, optional = true }
parking_lot = { workspace = true, optional = true }
send_wrapper = { workspace = true, features = ["futures"] }
serde-wasm-bindgen.workspace = true
serde_json = { workspace = true, optional = true }
tokio = { default-features = false, features = ["sync", "macros"], workspace = true }
url = { workspace = true, optional = true }
wasm-bindgen.workspace = true
wasm-bindgen-futures.workspace = true
web-sys = { workspace = true, optional = true }
2 changes: 1 addition & 1 deletion examples/browser-webrtc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub async fn run(address: String) -> Result<(), JsError> {
.set_swarm_config(|c| c.with_idle_connection_timeout(Duration::from_secs(30)))
.set_swarm_event_callback({
let body = body.clone();
move |_, e, _| {
move |_, _, e, _| {
body.append_p(&format!("{e:?}"))
.expect("failed to append <p>");
}
Expand Down
16 changes: 16 additions & 0 deletions src/builder.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
mod executor;
pub(crate) mod transport;

#[cfg(all(feature = "dns", target_arch = "wasm32"))]
pub(crate) mod dns_websys;

#[cfg(feature = "request-response")]
use crate::behaviour::request_response::RequestResponseConfig;
#[cfg(feature = "dns")]
Expand Down Expand Up @@ -812,6 +815,19 @@ where
self
}

/// Enables DNS with a specific resolver and configuration
#[cfg(target_arch = "wasm32")]
#[cfg(feature = "dns")]
pub fn enable_dns_with_resolver_and_config<F>(mut self, resolver: DnsResolver, f: F) -> Self
where
F: FnOnce(dns_websys::Config) -> dns_websys::Config + 'static,
{
self.transport_config.dns_resolver = Some(resolver);
self.transport_config.dns_config_fn = Box::new(f);
self.transport_config.enable_dns = true;
self
}

/// Enables WebRTC transport
#[cfg(feature = "webrtc")]
pub fn enable_webrtc(mut self) -> Self {
Expand Down
Loading
Loading