diff --git a/Cargo.lock b/Cargo.lock
index 105080d600..c56bb71bba 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2,21 +2,6 @@
# It is not intended for manual editing.
version = 4
-[[package]]
-name = "acto"
-version = "0.8.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "148541f13c28e3e840354ee4d6c99046c10be2c81068bbd23b9e3a38f95a917e"
-dependencies = [
- "parking_lot",
- "pin-project-lite",
- "rustc_version",
- "smol_str",
- "sync_wrapper",
- "tokio",
- "tracing",
-]
-
[[package]]
name = "addr2line"
version = "0.25.1"
@@ -2360,7 +2345,6 @@ dependencies = [
"iroh-dns",
"iroh-metrics",
"iroh-relay",
- "mainline",
"n0-error",
"n0-future",
"n0-tracing-test",
@@ -2389,7 +2373,6 @@ dependencies = [
"serde_json",
"smallvec",
"strum 0.28.0",
- "swarm-discovery",
"testdir",
"time",
"tokio",
@@ -4722,12 +4705,6 @@ dependencies = [
"serde",
]
-[[package]]
-name = "smol_str"
-version = "0.1.24"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fad6c857cbab2627dcf01ec85a623ca4e7dcb5691cbaa3d7fb7653671f0d09c9"
-
[[package]]
name = "socket2"
version = "0.6.3"
@@ -4878,21 +4855,6 @@ version = "2.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
-[[package]]
-name = "swarm-discovery"
-version = "0.6.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7a5e3cb18dc0532c89b4fd9f5c9a44cb2db3c15520b6fa37d604b878ba431afb"
-dependencies = [
- "acto",
- "hickory-proto 0.26.0",
- "rand 0.10.1",
- "socket2",
- "thiserror 2.0.18",
- "tokio",
- "tracing",
-]
-
[[package]]
name = "syn"
version = "2.0.117"
diff --git a/iroh/Cargo.toml b/iroh/Cargo.toml
index 0b603bd7a3..949708e81f 100644
--- a/iroh/Cargo.toml
+++ b/iroh/Cargo.toml
@@ -40,7 +40,6 @@ netwatch = "0.16"
papaya = { version = "0.2.3", default-features = false }
pin-project = "1"
portable-atomic = "1"
-mainline = { version = "6", optional = true }
noq = { version = "0.18.0", default-features = false, features = ["rustls"] }
noq-proto = { version = "0.17", default-features = false }
noq-udp = { version = "0.10", default-features = false }
@@ -69,8 +68,6 @@ pkcs8 = "0.11.0-rc.9"
# metrics
iroh-metrics = { version = "0.38", default-features = false }
-# mdns
-swarm-discovery = { version = "0.6.0", optional = true }
futures-util = "0.3"
# test_utils
@@ -154,8 +151,6 @@ default = ["metrics", "fast-apple-datapath", "portmapper", "tls-ring"]
portmapper = ["dep:portmapper"]
metrics = ["iroh-metrics/metrics", "iroh-relay/metrics", "portmapper?/metrics"]
test-utils = ["iroh-relay/test-utils", "iroh-relay/server", "dep:axum"]
-address-lookup-mdns = ["dep:swarm-discovery"]
-address-lookup-pkarr-dht = ["dep:mainline"]
# Enables fetching TLS trust anchors from the operating system
platform-verifier = ["iroh-relay/platform-verifier"]
qlog = ["noq/qlog"]
@@ -196,14 +191,6 @@ required-features = []
name = "connect-unreliable"
required-features = []
-[[example]]
-name = "dht_address_lookup"
-required-features = ["address-lookup-pkarr-dht"]
-
-[[example]]
-name = "mdns_address_lookup"
-required-features = ["address-lookup-mdns"]
-
[[example]]
name = "search"
required-features = []
diff --git a/iroh/examples/dht_address_lookup.rs b/iroh/examples/dht_address_lookup.rs
deleted file mode 100644
index 956dd55896..0000000000
--- a/iroh/examples/dht_address_lookup.rs
+++ /dev/null
@@ -1,110 +0,0 @@
-//! An example chat application using the iroh endpoint and
-//! pkarr address lookup.
-//!
-//! Starting the example without args creates a server that publishes its
-//! address to the DHT. Starting the example with an endpoint id as argument
-//! looks up the address of the endpoint id in the DHT and connects to it.
-//!
-//! You can look at the published pkarr DNS record using .
-//!
-//! To see what is going on, run with `RUST_LOG=iroh_pkarr_address_lookup=debug`.
-//!
-//! Note that while the DhtAddressLookup by default publishes only the home
-//! relay of the endpoint, this example explicitly removes the filter to publish
-//! all addresses.
-use clap::Parser;
-use iroh::{
- Endpoint, EndpointId,
- address_lookup::{AddrFilter, DhtAddressLookup},
- endpoint::presets,
-};
-use n0_error::{Result, StdResultExt};
-use tracing::warn;
-
-const CHAT_ALPN: &[u8] = b"pkarr-address-lookup-demo-chat";
-
-#[derive(Parser)]
-struct Args {
- /// The endpoint id to connect to. If not set, the program will start a server.
- endpoint_id: Option,
-}
-
-async fn chat_server() -> Result<()> {
- let secret_key = iroh::SecretKey::generate();
- let endpoint_id = secret_key.public();
- let address_lookup = DhtAddressLookup::builder().addr_filter(AddrFilter::unfiltered());
- let endpoint = Endpoint::builder(presets::N0)
- .alpns(vec![CHAT_ALPN.to_vec()])
- .secret_key(secret_key)
- .address_lookup(address_lookup)
- .bind()
- .await?;
- let zid = endpoint_id.to_z32();
- println!("Listening on {endpoint_id}");
- println!("pkarr z32: {zid}");
- println!("see https://app.pkarr.org/?pk={zid}");
- while let Some(incoming) = endpoint.accept().await {
- let accepting = match incoming.accept() {
- Ok(accepting) => accepting,
- Err(err) => {
- warn!("incoming connection failed: {err:#}");
- // we can carry on in these cases:
- // this can be caused by retransmitted datagrams
- continue;
- }
- };
- tokio::spawn(async move {
- let connection = accepting.await?;
- let remote_endpoint_id = connection.remote_id();
- println!("got connection from {remote_endpoint_id}");
- // just leave the tasks hanging. this is just an example.
- let (mut writer, mut reader) = connection.accept_bi().await.anyerr()?;
- let _copy_to_stdout = tokio::spawn(async move {
- tokio::io::copy(&mut reader, &mut tokio::io::stdout()).await
- });
- let _copy_from_stdin =
- tokio::spawn(
- async move { tokio::io::copy(&mut tokio::io::stdin(), &mut writer).await },
- );
- n0_error::Ok(())
- });
- }
- Ok(())
-}
-
-async fn chat_client(args: Args) -> Result<()> {
- let remote_endpoint_id = args.endpoint_id.unwrap();
- let secret_key = iroh::SecretKey::generate();
- let endpoint_id = secret_key.public();
- // note: we don't pass a secret key here, because we don't need to publish our address, don't spam the DHT
- let address_lookup = DhtAddressLookup::builder().no_publish();
- // we do not need to specify the alpn here, because we are not going to accept connections
- let endpoint = Endpoint::builder(presets::N0)
- .secret_key(secret_key)
- .address_lookup(address_lookup)
- .bind()
- .await?;
- println!("We are {endpoint_id} and connecting to {remote_endpoint_id}");
- let connection = endpoint.connect(remote_endpoint_id, CHAT_ALPN).await?;
- println!("connected to {remote_endpoint_id}");
- let (mut writer, mut reader) = connection.open_bi().await.anyerr()?;
- let _copy_to_stdout =
- tokio::spawn(async move { tokio::io::copy(&mut reader, &mut tokio::io::stdout()).await });
- let _copy_from_stdin =
- tokio::spawn(async move { tokio::io::copy(&mut tokio::io::stdin(), &mut writer).await });
- _copy_to_stdout.await.anyerr()?.anyerr()?;
- _copy_from_stdin.await.anyerr()?.anyerr()?;
- Ok(())
-}
-
-#[tokio::main]
-async fn main() -> Result<()> {
- tracing_subscriber::fmt::init();
- let args = Args::parse();
- if args.endpoint_id.is_some() {
- chat_client(args).await?;
- } else {
- chat_server().await?;
- }
- Ok(())
-}
diff --git a/iroh/examples/mdns_address_lookup.rs b/iroh/examples/mdns_address_lookup.rs
deleted file mode 100644
index f60a368076..0000000000
--- a/iroh/examples/mdns_address_lookup.rs
+++ /dev/null
@@ -1,86 +0,0 @@
-//! A small example showing how to get a list of endpoints that were discovered via [`iroh::address_lookup::MdnsAddressLookup`]. Mdns Address Lookup uses [`swarm-discovery`](https://crates.io/crates/swarm-discovery), an opinionated implementation of mDNS to discover other endpoints in the local network.
-//!
-//! This example creates an iroh endpoint, a few additional iroh endpoints to discover, waits a few seconds, and reports all of the iroh EndpointIds (also called `[iroh::key::PublicKey]`s) it has discovered.
-//!
-//! This is an async, non-determinate process, so the number of EndpointIDs discovered each time may be different. If you have other iroh endpoints or iroh endpoints with [`address_lookup::MdnsAddressLookup`] enabled, it may discover those endpoints as well.
-use std::time::Duration;
-
-use iroh::{Endpoint, EndpointId, address_lookup, endpoint::presets, endpoint_info::UserData};
-use n0_error::Result;
-use n0_future::StreamExt;
-use tokio::task::JoinSet;
-
-#[tokio::main]
-async fn main() -> Result<()> {
- tracing_subscriber::fmt::init();
- println!("Discovering Local Endpoints Example!");
-
- let ep = Endpoint::bind(presets::N0).await?;
- let endpoint_id = ep.id();
-
- let mdns = address_lookup::MdnsAddressLookup::builder().build(endpoint_id)?;
- ep.address_lookup()?.add(mdns.clone());
-
- println!("Created endpoint {}", endpoint_id.fmt_short());
-
- let user_data = UserData::try_from(String::from("local-endpoints-example"))?;
-
- let ud = user_data.clone();
- let address_lookup_stream_task = tokio::spawn(async move {
- let mut address_lookup_stream = mdns.subscribe().await;
- let mut discovered_endpoints: Vec = vec![];
- while let Some(event) = address_lookup_stream.next().await {
- match event {
- address_lookup::DiscoveryEvent::Discovered { endpoint_info, .. } => {
- // if there is no user data, or the user data
- // does not indicate that the discovered endpoint
- // is a part of the example, ignore it
- match endpoint_info.data.user_data() {
- Some(user_data) if &ud == user_data => {}
- _ => {
- tracing::error!(
- "found endpoint with unexpected user data, ignoring it"
- );
- continue;
- }
- }
-
- // if we've already found this endpoint, ignore it
- // otherwise announce that we have found a new endpoint
- if discovered_endpoints.contains(&endpoint_info.endpoint_id) {
- continue;
- } else {
- discovered_endpoints.push(endpoint_info.endpoint_id);
- println!("Found endpoint {}!", endpoint_info.endpoint_id.fmt_short());
- }
- }
- address_lookup::DiscoveryEvent::Expired { .. } => {}
- _ => {}
- };
- }
- });
-
- let mut set = JoinSet::new();
- let endpoint_count = 5;
- for _ in 0..endpoint_count {
- let ud = user_data.clone();
- set.spawn(async move {
- let ep = Endpoint::bind(presets::N0).await?;
- ep.address_lookup()?
- .add(address_lookup::MdnsAddressLookup::builder().build(ep.id())?);
- ep.set_user_data_for_address_lookup(Some(ud));
- tokio::time::sleep(Duration::from_secs(3)).await;
- ep.close().await;
- n0_error::Ok(())
- });
- }
-
- set.join_all().await.iter().for_each(|res| {
- if let Err(e) = res {
- tracing::error!("{e}");
- }
- });
- ep.close().await;
- address_lookup_stream_task.abort();
- Ok(())
-}
diff --git a/iroh/examples/transfer.rs b/iroh/examples/transfer.rs
index 98f088cc77..1be123c437 100644
--- a/iroh/examples/transfer.rs
+++ b/iroh/examples/transfer.rs
@@ -581,18 +581,9 @@ impl EndpointArgs {
let endpoint = builder.alpns(vec![TRANSFER_ALPN.to_vec()]).bind().await?;
if self.mdns {
- #[cfg(feature = "address-lookup-mdns")]
- {
- use iroh::address_lookup::MdnsAddressLookup;
-
- endpoint
- .address_lookup()?
- .add(MdnsAddressLookup::builder().build(endpoint.id())?);
- }
- #[cfg(not(feature = "address-lookup-mdns"))]
- {
- n0_error::bail_any!("Must have the `mdns` enabled when using the `--mdns` flag");
- }
+ n0_error::bail_any!(
+ "mDNS address lookup is no longer built into iroh; use the `iroh-mdns-address-lookup` crate instead",
+ );
}
if self.relay_only {
diff --git a/iroh/src/address_lookup.rs b/iroh/src/address_lookup.rs
index 7348ae4d97..d32e8651ec 100644
--- a/iroh/src/address_lookup.rs
+++ b/iroh/src/address_lookup.rs
@@ -43,11 +43,12 @@
//! - The [`PkarrResolver`] which can perform lookups from designated [pkarr relay servers]
//! using HTTP.
//!
-//! - [`address_lookup::MdnsAddressLookup`]: mdns::MdnsAddressLookup which uses the crate `swarm-discovery`, an
-//! opinionated mDNS implementation, to discover endpoints on the local network.
+//! mDNS-based and Mainline-DHT-based Address Lookup services live in
+//! separate crates: [`iroh-mdns-address-lookup`] and
+//! [`iroh-mainline-address-lookup`].
//!
-//! - The [`address_lookup::DhtAddressLookup`] also uses the [`pkarr`] system but can also publish and lookup
-//! records to/from the Mainline DHT. It requires enabling the `address-lookup-pkarr-dht` feature.
+//! [`iroh-mdns-address-lookup`]: https://docs.rs/iroh-mdns-address-lookup
+//! [`iroh-mainline-address-lookup`]: https://docs.rs/iroh-mainline-address-lookup
//!
//! To use multiple Address Lookup'ssimultaneously you can call [`Builder::address_lookup`].
//! This will use [`AddressLookupServices`] under the hood, which performs lookups to all
@@ -89,31 +90,6 @@
//! # }
//! ```
//!
-//! To also enable [`address_lookup::MdnsAddressLookup`] it can be added as another service.
-//!
-//! ```no_run
-//! #[cfg(feature = "address-lookup-mdns")]
-//! # {
-//! # use iroh::{
-//! # address_lookup::{self, AddrFilter, PkarrPublisher},
-//! # endpoint::{presets, RelayMode},
-//! # Endpoint, SecretKey,
-//! # };
-//! #
-//! # async fn wrapper() -> n0_error::Result<()> {
-//! let ep = Endpoint::builder(presets::Minimal)
-//! .relay_mode(RelayMode::Default)
-//! .addr_filter(AddrFilter::relay_only())
-//! .address_lookup(PkarrPublisher::n0_dns())
-//! .address_lookup(address_lookup::DnsAddressLookup::n0_dns())
-//! .address_lookup(address_lookup::MdnsAddressLookup::builder())
-//! .bind()
-//! .await?;
-//! # Ok(())
-//! # }
-//! # }
-//! ```
-//!
//! [`EndpointAddr`]: iroh_base::EndpointAddr
//! [`RelayUrl`]: crate::RelayUrl
//! [`Builder::address_lookup`]: crate::endpoint::Builder::address_lookup
@@ -122,9 +98,7 @@
//! [`PkarrResolver`]: pkarr::PkarrResolver
//! [`PkarrPublisher`]: pkarr::PkarrPublisher
//! [`PkarrPublisherBuilder::addr_filter`]: pkarr::PkarrPublisherBuilder::addr_filter
-//! [`address_lookup::DhtAddressLookup`]: crate::address_lookup::DhtAddressLookup
//! [pkarr relay servers]: https://pkarr.org/#servers
-//! [`address_lookup::MdnsAddressLookup`]: crate::address_lookup::MdnsAddressLookup
//! [`MemoryLookup`]: memory::MemoryLookup
use std::{
@@ -145,18 +119,12 @@ use crate::{Endpoint, endpoint::EndpointError};
#[cfg(not(wasm_browser))]
pub mod dns;
-#[cfg(feature = "address-lookup-mdns")]
-pub mod mdns;
pub mod memory;
pub mod pkarr;
#[cfg(not(wasm_browser))]
pub use dns::*;
-#[cfg(feature = "address-lookup-mdns")]
-pub use mdns::*;
pub use memory::*;
-#[cfg(feature = "address-lookup-pkarr-dht")]
-pub use pkarr::dht::*;
pub use pkarr::*;
/// Trait for structs that can be converted into [`AddressLookup`]s.
diff --git a/iroh/src/address_lookup/mdns.rs b/iroh/src/address_lookup/mdns.rs
deleted file mode 100644
index 44e4175afc..0000000000
--- a/iroh/src/address_lookup/mdns.rs
+++ /dev/null
@@ -1,944 +0,0 @@
-//! An address lookup service that uses an mdns-like service to discover and lookup the addresses of local endpoints.
-//!
-//! This allows you to use an mdns-like swarm discovery service to find address information about endpoints that are on your local network, no relay or outside internet needed.
-//! See the [`swarm-discovery`](https://crates.io/crates/swarm-discovery) crate for more details.
-//!
-//! When [`MdnsAddressLookup`] is enabled, it's possible to get a list of the locally discovered endpoints by filtering a list of `RemoteInfo`s.
-//!
-//! In order to get a list of locally discovered addresses, you must call `MdnsAddressLookup::subscribe` to subscribe
-//! to a stream of discovered addresses.
-//!
-//! ```no_run
-//! use std::time::Duration;
-//!
-//! use iroh::{
-//! RelayMode, SecretKey,
-//! address_lookup::{DiscoveryEvent, MdnsAddressLookup},
-//! endpoint::{Endpoint, Source, presets},
-//! };
-//! use n0_future::StreamExt;
-//!
-//! #[tokio::main]
-//! async fn main() {
-//! let recent = Duration::from_secs(600); // 10 minutes in seconds
-//! let endpoint = Endpoint::bind(presets::Minimal).await.unwrap();
-//!
-//! // Register the Address Lookupwith the endpoint
-//! let mdns = MdnsAddressLookup::builder().build(endpoint.id()).unwrap();
-//! endpoint.address_lookup().unwrap().add(mdns.clone());
-//!
-//! // Subscribe to the mdns discovery events
-//! let mut events = mdns.subscribe().await;
-//! while let Some(event) = events.next().await {
-//! match event {
-//! DiscoveryEvent::Discovered { endpoint_info, .. } => {
-//! println!("MDNS discovered: {:?}", endpoint_info);
-//! }
-//! DiscoveryEvent::Expired { endpoint_id } => {
-//! println!("MDNS expired: {endpoint_id}");
-//! }
-//! _ => {}
-//! }
-//! }
-//! }
-//! ```
-//!
-//! ## Filtering
-//!
-//! By default, [`MdnsAddressLookup`] publishes all addresses it receives:
-//! direct IP addresses and up to one [`RelayUrl`]. The following constraints apply regardless
-//! of any user-supplied filter:
-//!
-//! - Only the first [`RelayUrl`] in the address set is published.
-//! - A [`RelayUrl`] longer than 249 bytes is silently dropped.
-//!
-//! You can supply an [`AddrFilter`] via [`MdnsAddressLookupBuilder::addr_filter`] to
-//! control which addresses are published and in what order. The filter is applied before the
-//! constraints above, so for example you can use it to exclude relay URLs entirely or to
-//! prioritize certain addresses.
-//!
-//! [`AddrFilter`]: crate::address_lookup::AddrFilter
-//! [`RelayUrl`]: iroh_base::RelayUrl
-use std::{
- collections::{BTreeSet, HashMap},
- net::{IpAddr, SocketAddr},
- str::FromStr,
- sync::Arc,
-};
-
-use iroh_base::{EndpointId, PublicKey};
-use n0_future::{
- Stream,
- boxed::BoxStream,
- task::{self, AbortOnDropHandle, JoinSet},
- time::{self, Duration},
-};
-use n0_watcher::{Watchable, Watcher as _};
-use swarm_discovery::{Discoverer, DropGuard, IpClass, Peer};
-use tokio::sync::mpsc::{self, error::TrySendError};
-use tracing::{Instrument, debug, error, info_span, trace, warn};
-
-use super::AddressLookupBuilder;
-use crate::{
- Endpoint,
- address_lookup::{
- AddrFilter, AddressLookup, AddressLookupBuilderError, EndpointData, EndpointInfo,
- Error as AddressLookupError, Item as AddressLookupItem,
- },
-};
-
-/// The n0 local service name.
-const N0_SERVICE_NAME: &str = "irohv1";
-
-/// Name of this address lookup service.
-///
-/// Used as the `provenance` field in [`AddressLookupItem`]s.
-///
-/// Used in the [`crate::endpoint::Source::AddressLookup`] enum variant as the `name`.
-pub const NAME: &str = "mdns";
-
-/// The key of the attribute under which the `UserData` is stored in
-/// the TXT record supported by swarm-discovery.
-const USER_DATA_ATTRIBUTE: &str = "user-data";
-
-/// How long we will wait before we stop attempting to resolve an endpoint ID to an address.
-const LOOKUP_DURATION: Duration = Duration::from_secs(10);
-
-/// The key of the attribute under which the `RelayUrl` is stored in
-/// the TXT record supported by swarm-discovery.
-const RELAY_URL_ATTRIBUTE: &str = "relay";
-
-/// Address Lookup using `swarm-discovery`, a variation on mdns.
-#[derive(Debug, Clone)]
-pub struct MdnsAddressLookup {
- #[allow(dead_code)]
- handle: Arc>,
- sender: mpsc::Sender,
- advertise: bool,
- /// When `local_addrs` changes, we re-publish our info.
- local_addrs: Watchable