address-lookup-pkarr-dht only.Expand description
Pkarr based address lookup for iroh, supporting both relay servers and the DHT.
+Module dht
address-lookup-pkarr-dht only.Expand description
Pkarr based address lookup for iroh, supporting both relay servers and the DHT.
This module contains pkarr-based address lookup for iroh which can use both pkarr relay servers as well as the Mainline DHT directly. See the pkarr module for an overview of pkarr.
diff --git a/pr/4026/docs/iroh/address_lookup/pkarr/dht/struct.DhtAddressLookup.html b/pr/4026/docs/iroh/address_lookup/pkarr/dht/struct.DhtAddressLookup.html index 23c5105122..9342238ae6 100644 --- a/pr/4026/docs/iroh/address_lookup/pkarr/dht/struct.DhtAddressLookup.html +++ b/pr/4026/docs/iroh/address_lookup/pkarr/dht/struct.DhtAddressLookup.html @@ -8,8 +8,8 @@ a background task that periodically publishes the endpoint address. To change this behavior, useBuilder::addr_filter and set it to e.g. AddrFilter::unfiltered.
This can be useful to enable publishing IP addresses if the iroh endpoint is reachable via public
IP addresses.
-Implementations§
Source§impl DhtAddressLookup
impl DhtAddressLookup
Sourcepub fn builder() -> Builder
pub fn builder() -> Builder
Creates a new builder for DhtAddressLookup.
Trait Implementations§
Source§impl AddressLookup for DhtAddressLookup
impl AddressLookup for DhtAddressLookup
Source§fn publish(&self, data: &EndpointData)
fn publish(&self, data: &EndpointData)
EndpointData to the Address Lookup mechanism. Read moreImplementations§
Source§impl DhtAddressLookup
impl DhtAddressLookup
Sourcepub fn builder() -> Builder
pub fn builder() -> Builder
Creates a new builder for DhtAddressLookup.
Trait Implementations§
Source§impl AddressLookup for DhtAddressLookup
impl AddressLookup for DhtAddressLookup
Source§fn publish(&self, data: &EndpointData)
fn publish(&self, data: &EndpointData)
EndpointData to the Address Lookup mechanism. Read moreSource§fn resolve(
&self,
endpoint_id: EndpointId,
) -> Option<BoxStream<Result<AddressLookupItem, AddressLookupError>>>
fn resolve( &self, endpoint_id: EndpointId, ) -> Option<BoxStream<Result<AddressLookupItem, AddressLookupError>>>
Source§impl Clone for DhtAddressLookup
impl Clone for DhtAddressLookup
Source§fn clone(&self) -> DhtAddressLookup
fn clone(&self) -> DhtAddressLookup
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for DhtAddressLookup
impl !RefUnwindSafe for DhtAddressLookup
impl Send for DhtAddressLookup
impl Sync for DhtAddressLookup
impl Unpin for DhtAddressLookup
impl !UnwindSafe for DhtAddressLookup
Blanket Implementations§
Source§impl<T> AddressLookupBuilder for Twhere
diff --git a/pr/4026/docs/iroh/address_lookup/trait.AddressLookup.html b/pr/4026/docs/iroh/address_lookup/trait.AddressLookup.html
index 02dd598301..c83427903d 100644
--- a/pr/4026/docs/iroh/address_lookup/trait.AddressLookup.html
+++ b/pr/4026/docs/iroh/address_lookup/trait.AddressLookup.html
@@ -34,4 +34,4 @@ work.
impl<T> AddressLookupBuilder for Twhere
diff --git a/pr/4026/docs/iroh/address_lookup/trait.AddressLookup.html b/pr/4026/docs/iroh/address_lookup/trait.AddressLookup.html
index 02dd598301..c83427903d 100644
--- a/pr/4026/docs/iroh/address_lookup/trait.AddressLookup.html
+++ b/pr/4026/docs/iroh/address_lookup/trait.AddressLookup.html
@@ -34,4 +34,4 @@ work.
Implementations on Foreign Types§
Source§impl<T: AddressLookup> AddressLookup for Arc<T>
impl<T: AddressLookup> AddressLookup for Arc<T>
Implementors§
impl AddressLookup for DnsAddressLookup
wasm_browser only.impl AddressLookup for MdnsAddressLookup
address-lookup-mdns only.impl AddressLookup for MemoryLookup
impl AddressLookup for DhtAddressLookup
address-lookup-pkarr-dht only.impl AddressLookup for PkarrPublisher
impl AddressLookup for PkarrResolver
impl AddressLookup for ConcurrentAddressLookup
impl<T: AddressLookup> AddressLookup for FilteredAddressLookup<T>
Implementors§
impl AddressLookup for DnsAddressLookup
wasm_browser only.impl AddressLookup for MdnsAddressLookup
address-lookup-mdns only.impl AddressLookup for MemoryLookup
impl AddressLookup for DhtAddressLookup
address-lookup-pkarr-dht only.impl AddressLookup for PkarrPublisher
impl AddressLookup for PkarrResolver
impl AddressLookup for ConcurrentAddressLookup
impl<T: AddressLookup> AddressLookup for FilteredAddressLookup<T>
endpoint_id_from_txt_name
pub fn endpoint_id_from_txt_name(name: &str) -> Result<EndpointId, ParseError>Expand description
Parses a [EndpointId] from iroh DNS name.
endpoint_id_from_txt_name
pub fn endpoint_id_from_txt_name(name: &str) -> Result<EndpointId, ParseError>Expand description
Parses a EndpointId from iroh DNS name.
Takes a DNS name and expects the first label to be IROH_TXT_NAME and the second
-label to be a z32 encoded [EndpointId]. Ignores subsequent labels.
EndpointId. Ignores subsequent labels.
Module attrs
Expand description
Support for handling DNS resource records for dialing by [EndpointId].
Module attrs
Expand description
Support for handling DNS resource records for dialing by EndpointId.
DNS records are published under the following names:
_iroh.<z32-endpoint-id>.<origin-domain> TXT
The returned TXT records must contain a string value of the form key=value as defined
in RFC1464.
Structs§
- TxtAttrs
- Attributes parsed from
IROH_TXT_NAMETXT records.
Enums§
- Encoding
Error - Iroh
Attr - The attributes supported by iroh for
IROH_TXT_NAMEDNS resource records. - Parse
Error
Constants§
- IROH_
TXT_ NAME - The DNS name for the iroh TXT record.
Functions§
- endpoint_
id_ from_ txt_ name - Parses a [
EndpointId] from iroh DNS name.
Structs§
- TxtAttrs
- Attributes parsed from
IROH_TXT_NAMETXT records.
Enums§
- Encoding
Error - Iroh
Attr - The attributes supported by iroh for
IROH_TXT_NAMEDNS resource records. - Parse
Error
Constants§
- IROH_
TXT_ NAME - The DNS name for the iroh TXT record.
Functions§
- endpoint_
id_ from_ txt_ name - Parses a
EndpointIdfrom iroh DNS name.
FromStr and
Display.
Implementations§
Source§impl<T: FromStr + Display + Hash + Ord> TxtAttrs<T>
impl<T: FromStr + Display + Hash + Ord> TxtAttrs<T>
Sourcepub fn from_parts(
- endpoint_id: EndpointId,
+ endpoint_id: EndpointId,
pairs: impl Iterator<Item = (T, String)>,
) -> Self
pub fn from_parts( - endpoint_id: EndpointId, + endpoint_id: EndpointId, pairs: impl Iterator<Item = (T, String)>, ) -> Self
Creates TxtAttrs from an endpoint id and an iterator of key-value pairs.
Sourcepub fn from_strings(
- endpoint_id: EndpointId,
+ endpoint_id: EndpointId,
strings: impl Iterator<Item = String>,
) -> Result<Self, ParseError>
pub fn from_strings( - endpoint_id: EndpointId, + endpoint_id: EndpointId, strings: impl Iterator<Item = String>, ) -> Result<Self, ParseError>
Creates TxtAttrs from an endpoint id and an iterator of “{key}={value}” strings.
Sourcepub fn endpoint_id(&self) -> EndpointId
pub fn endpoint_id(&self) -> EndpointId
Returns the endpoint id.
+Sourcepub fn endpoint_id(&self) -> EndpointId
pub fn endpoint_id(&self) -> EndpointId
Returns the endpoint id.
Sourcepub fn from_txt_lookup(
name: String,
lookup: impl Iterator<Item = impl Display>,
@@ -24,10 +24,10 @@ values that implement Sourcepub fn to_txt_strings(&self) -> impl Iterator<Item = String> + '_
Converts to {key}={value} strings.
pub fn from_txt_lookup(
name: String,
lookup: impl Iterator<Item = impl Display>,
@@ -24,10 +24,10 @@ values that implement Sourcepub fn to_txt_strings(&self) -> impl Iterator<Item = String> + '_
Converts to {key}={value} strings.
pub fn to_txt_strings(&self) -> impl Iterator<Item = String> + '_
Converts to {key}={value} strings.
Sourcepub fn to_pkarr_signed_packet(
&self,
- secret_key: &SecretKey,
+ secret_key: &SecretKey,
ttl: u32,
) -> Result<SignedPacket, EncodingError>
pub fn to_pkarr_signed_packet( &self, - secret_key: &SecretKey, + secret_key: &SecretKey, ttl: u32, ) -> Result<SignedPacket, EncodingError>
Creates a pkarr::SignedPacket
This constructs a DNS packet and signs it with a [SecretKey].
This constructs a DNS packet and signs it with a SecretKey.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for TxtAttrs<T>
impl<T> RefUnwindSafe for TxtAttrs<T>where
T: RefUnwindSafe,
impl<T> Send for TxtAttrs<T>where
T: Send,
impl<T> Sync for TxtAttrs<T>where
diff --git a/pr/4026/docs/iroh_dns/enum.DecodingError.html b/pr/4026/docs/iroh_dns/enum.DecodingError.html
index ba55e0c71f..43b41092d1 100644
--- a/pr/4026/docs/iroh_dns/enum.DecodingError.html
+++ b/pr/4026/docs/iroh_dns/enum.DecodingError.html
@@ -8,12 +8,12 @@
meta: Meta,
},
InvalidKey {
- source: KeyParsingError,
+ source: KeyParsingError,
meta: Meta,
},
}Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.Trait Implementations§
Source§impl Debug for DecodingError
Source§impl Display for DecodingError
Source§impl Error for DecodingError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more1.0.0 · Source§fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()Source§impl From<DecodingError> for AnyError
Source§fn from(value: DecodingError) -> AnyError
Converts to this type from the input type.Source§impl From<DecodingError> for ParseError
Source§fn from(source: DecodingError) -> Self
Converts to this type from the input type.Source§impl StackError for DecodingError
Source§fn as_std(&self) -> &(dyn Error + Send + Sync + 'static)
Returns this error as a std error reference.Source§fn into_std(self: Box<Self>) -> Box<dyn Error + Send + Sync>
Returns this error as a std error.Source§fn fmt_message(&self, f: &mut Formatter<'_>) -> Result
Returns the next source in the chain, if any.Source§fn is_transparent(&self) -> bool
Returns whether this error is transparent and should be skipped in reports.Auto Trait Implementations§
§impl Freeze for DecodingError
§impl RefUnwindSafe for DecodingError
§impl Send for DecodingError
§impl Sync for DecodingError
§impl Unpin for DecodingError
§impl UnwindSafe for DecodingError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
diff --git a/pr/4026/docs/iroh_dns/index.html b/pr/4026/docs/iroh_dns/index.html
index e276c05581..f8d2fcb8a6 100644
--- a/pr/4026/docs/iroh_dns/index.html
+++ b/pr/4026/docs/iroh_dns/index.html
@@ -1,5 +1,5 @@
iroh_dns - Rust Crate iroh_dns
Expand description
DNS-based endpoint discovery for iroh.
This crate contains the core types for publishing and resolving iroh endpoint
information via DNS, using the pkarr signed packet format.
-Modules§
- attrs
- Support for handling DNS resource records for dialing by [
EndpointId]. - pkarr
- Pkarr signed packet encoding.
Enums§
Traits§
- Endpoint
IdExt - Extension methods for [
EndpointId] to encode to and decode from z-base-32,
+
Modules§
- attrs
- Support for handling DNS resource records for dialing by
EndpointId. - pkarr
- Pkarr signed packet encoding.
Enums§
Traits§
- Endpoint
IdExt - Extension methods for
EndpointId to encode to and decode from z-base-32,
which is the encoding used by pkarr domain names.
\ No newline at end of file
diff --git a/pr/4026/docs/iroh_dns/pkarr/struct.SignedPacket.html b/pr/4026/docs/iroh_dns/pkarr/struct.SignedPacket.html
index 4d719bcc57..651c5a897c 100644
--- a/pr/4026/docs/iroh_dns/pkarr/struct.SignedPacket.html
+++ b/pr/4026/docs/iroh_dns/pkarr/struct.SignedPacket.html
@@ -3,7 +3,7 @@
The DNS packet must be at most 1000 bytes. Total max size is 1104 bytes.
Implementations§
Source§impl SignedPacket
Sourcepub fn from_txt_strings(
- secret_key: &SecretKey,
+ secret_key: &SecretKey,
name: &str,
values: impl IntoIterator<Item = impl AsRef<str>>,
ttl: u32,
@@ -11,7 +11,7 @@
This is the common case: multiple TXT values under the same DNS name (e.g. "_iroh").
Sourcepub fn from_bytes(bytes: &[u8]) -> Result<SignedPacket, SignedPacketVerifyError>
Parse and verify a signed packet from its wire representation.
Sourcepub fn from_relay_payload(
- public_key: &PublicKey,
+ public_key: &PublicKey,
payload: &[u8],
) -> Result<SignedPacket, SignedPacketVerifyError>
Create from a public key and relay payload (signature + timestamp + dns).
Sourcepub fn from_bytes_unchecked(
@@ -20,8 +20,8 @@
Still validates minimum length and DNS parsing.
Sourcepub fn to_relay_payload(&self) -> Vec<u8> ⓘ
Return the relay payload (everything after the public key).
-Sourcepub fn public_key(&self) -> PublicKey
Return the public key.
-Sourcepub fn public_key(&self) -> PublicKey
Return the public key.
+Sourcepub fn encoded_packet(&self) -> &[u8] ⓘ
Return the encoded DNS packet bytes.
Sourcepub fn txt_records(&self, name: &str) -> Vec<String>
Iterate over TXT records under a specific DNS name.
diff --git a/pr/4026/docs/iroh_dns/trait.EndpointIdExt.html b/pr/4026/docs/iroh_dns/trait.EndpointIdExt.html
index bdd3ab70e4..4ee78decb2 100644
--- a/pr/4026/docs/iroh_dns/trait.EndpointIdExt.html
+++ b/pr/4026/docs/iroh_dns/trait.EndpointIdExt.html
@@ -1,9 +1,9 @@
EndpointIdExt in iroh_dns - Rust EndpointIdExt
pub trait EndpointIdExt {
// Required methods
fn to_z32(&self) -> String;
- fn from_z32(s: &str) -> Result<EndpointId, DecodingError>;
-}
Expand description
Extension methods for [EndpointId] to encode to and decode from z-base-32,
+ fn from_z32(s: &str) -> Result<EndpointId, DecodingError>;
+}Expand description
Extension methods for EndpointId to encode to and decode from z-base-32,
which is the encoding used by pkarr domain names.
-
Required Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl EndpointIdExt for EndpointId
Implementors§
\ No newline at end of file
+Required Methods§
Sourcefn to_z32(&self) -> String
Encodes a EndpointId in z-base-32 encoding.
+Sourcefn from_z32(s: &str) -> Result<EndpointId, DecodingError>
Parses a EndpointId from z-base-32 encoding.
+Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl EndpointIdExt for EndpointId
Implementors§
\ No newline at end of file
diff --git a/pr/4026/docs/src/iroh/address_lookup/pkarr/dht.rs.html b/pr/4026/docs/src/iroh/address_lookup/pkarr/dht.rs.html
index d8f61d7a24..60ec9fd9e8 100644
--- a/pr/4026/docs/src/iroh/address_lookup/pkarr/dht.rs.html
+++ b/pr/4026/docs/src/iroh/address_lookup/pkarr/dht.rs.html
@@ -242,131 +242,128 @@
242 }
243
244 /// Periodically publishes the endpoint address to the DHT.
-245 async fn publish_loop(self, public_key_bytes: [u8; 32], item: MutableItem) {
+245 async fn publish_loop(self, signed_packet: SignedPacket) {
246 let this = self;
-247 let z32 = iroh_base::PublicKey::try_from(public_key_bytes.as_slice())
-248 .expect("valid key")
-249 .to_z32();
-250 loop {
-251 let res = this
-252 .0
-253 .dht
-254 .clone()
-255 .as_async()
-256 .put_mutable(item.clone(), None)
-257 .await;
-258 match res {
-259 Ok(_) => {
-260 tracing::debug!("pkarr publish success. published under {z32}");
-261 }
-262 Err(e) => {
-263 tracing::warn!("pkarr publish error: {}", e);
-264 }
-265 }
-266 time::sleep(this.0.republish_delay).await;
-267 }
-268 }
-269}
-270
-271impl AddressLookup for DhtAddressLookup {
-272 fn publish(&self, data: &EndpointData) {
-273 let Some(keypair) = &self.0.secret_key else {
-274 tracing::debug!("no keypair set, not publishing");
-275 return;
-276 };
-277
-278 // apply user-supplied filter
-279 let data = data.apply_filter(&self.0.filter).into_owned();
-280
-281 if !data.has_addrs() {
-282 tracing::debug!("no relay url or direct addresses in endpoint data, not publishing");
-283 return;
-284 }
-285
-286 tracing::debug!("publishing {data:?}");
-287 let info = EndpointInfo::from_parts(keypair.public(), data);
-288 let Ok(signed_packet) = info.to_pkarr_signed_packet(keypair, self.0.ttl) else {
-289 tracing::warn!("failed to create signed packet");
-290 return;
-291 };
-292 let item = signed_packet_to_mutable_item(&signed_packet);
-293 let public_key_bytes = *keypair.public().as_bytes();
-294 let this = self.clone();
-295 let curr = task::spawn(this.publish_loop(public_key_bytes, item));
-296 let mut task = self.0.task.lock().expect("poisoned");
-297 *task = Some(AbortOnDropHandle::new(curr));
-298 }
-299
-300 fn resolve(
-301 &self,
-302 endpoint_id: EndpointId,
-303 ) -> Option<BoxStream<Result<AddressLookupItem, AddressLookupError>>> {
-304 let z32 = endpoint_id.to_z32();
-305 tracing::info!("resolving {} as {}", endpoint_id, z32);
-306 let address_lookup = self.0.clone();
-307 let public_key_bytes = *endpoint_id.as_bytes();
-308 let stream = n0_future::stream::once_future(async move {
-309 address_lookup.resolve_dht(&public_key_bytes).await
-310 })
-311 .filter_map(|x| x)
-312 .boxed();
-313 Some(stream)
-314 }
-315}
-316
-317#[cfg(test)]
-318mod tests {
-319 use std::collections::BTreeSet;
-320
-321 use iroh_base::{RelayUrl, TransportAddr};
-322 use mainline::Testnet;
-323 use n0_error::{Result, StdResultExt};
-324 use n0_tracing_test::traced_test;
-325 use url::Url;
-326
-327 use super::*;
-328
-329 #[tokio::test]
-330 #[ignore = "flaky"]
-331 #[traced_test]
-332 async fn dht_address_lookup_smoke() -> Result {
-333 let secret = SecretKey::generate();
-334 let testnet = Testnet::new_async(3).await.anyerr()?;
-335 let mut dht_builder = DhtBuilder::default();
-336 dht_builder.bootstrap(&testnet.bootstrap);
-337 let address_lookup = DhtAddressLookup::builder()
-338 .secret_key(secret.clone())
-339 .dht_builder(dht_builder)
-340 .addr_filter(AddrFilter::unfiltered())
-341 .build()?;
-342
-343 let relay_url: RelayUrl = Url::parse("https://example.com").anyerr()?.into();
+247 let z32 = signed_packet.public_key().to_z32();
+248 let item = signed_packet_to_mutable_item(&signed_packet);
+249 loop {
+250 let res = this
+251 .0
+252 .dht
+253 .clone()
+254 .as_async()
+255 .put_mutable(item.clone(), None)
+256 .await;
+257 match res {
+258 Ok(_) => {
+259 tracing::debug!("pkarr publish success. published under {z32}");
+260 }
+261 Err(e) => {
+262 tracing::warn!("pkarr publish error: {}", e);
+263 }
+264 }
+265 time::sleep(this.0.republish_delay).await;
+266 }
+267 }
+268}
+269
+270impl AddressLookup for DhtAddressLookup {
+271 fn publish(&self, data: &EndpointData) {
+272 let Some(keypair) = &self.0.secret_key else {
+273 tracing::debug!("no keypair set, not publishing");
+274 return;
+275 };
+276
+277 // apply user-supplied filter
+278 let data = data.apply_filter(&self.0.filter).into_owned();
+279
+280 if !data.has_addrs() {
+281 tracing::debug!("no relay url or direct addresses in endpoint data, not publishing");
+282 return;
+283 }
+284
+285 tracing::debug!("publishing {data:?}");
+286 let info = EndpointInfo::from_parts(keypair.public(), data);
+287 let Ok(signed_packet) = info.to_pkarr_signed_packet(keypair, self.0.ttl) else {
+288 tracing::warn!("failed to create signed packet");
+289 return;
+290 };
+291 let this = self.clone();
+292 let curr = task::spawn(this.publish_loop(signed_packet));
+293 let mut task = self.0.task.lock().expect("poisoned");
+294 *task = Some(AbortOnDropHandle::new(curr));
+295 }
+296
+297 fn resolve(
+298 &self,
+299 endpoint_id: EndpointId,
+300 ) -> Option<BoxStream<Result<AddressLookupItem, AddressLookupError>>> {
+301 let z32 = endpoint_id.to_z32();
+302 tracing::info!("resolving {} as {}", endpoint_id, z32);
+303 let address_lookup = self.0.clone();
+304 let public_key_bytes = *endpoint_id.as_bytes();
+305 let stream = n0_future::stream::once_future(async move {
+306 address_lookup.resolve_dht(&public_key_bytes).await
+307 })
+308 .filter_map(|x| x)
+309 .boxed();
+310 Some(stream)
+311 }
+312}
+313
+314#[cfg(test)]
+315mod tests {
+316 use std::collections::BTreeSet;
+317
+318 use iroh_base::{RelayUrl, TransportAddr};
+319 use mainline::Testnet;
+320 use n0_error::{Result, StdResultExt};
+321 use n0_tracing_test::traced_test;
+322 use url::Url;
+323
+324 use super::*;
+325
+326 #[tokio::test]
+327 #[ignore = "flaky"]
+328 #[traced_test]
+329 async fn dht_address_lookup_smoke() -> Result {
+330 let secret = SecretKey::generate();
+331 let testnet = Testnet::new_async(3).await.anyerr()?;
+332 let mut dht_builder = DhtBuilder::default();
+333 dht_builder.bootstrap(&testnet.bootstrap);
+334 let address_lookup = DhtAddressLookup::builder()
+335 .secret_key(secret.clone())
+336 .dht_builder(dht_builder)
+337 .addr_filter(AddrFilter::unfiltered())
+338 .build()?;
+339
+340 let relay_url: RelayUrl = Url::parse("https://example.com").anyerr()?.into();
+341
+342 let data = EndpointData::from_iter([TransportAddr::Relay(relay_url.clone())]);
+343 address_lookup.publish(&data);
344
-345 let data = EndpointData::from_iter([TransportAddr::Relay(relay_url.clone())]);
-346 address_lookup.publish(&data);
-347
-348 // publish is fire and forget, so we have no way to wait until it is done.
-349 tokio::time::timeout(Duration::from_secs(30), async move {
-350 loop {
-351 tokio::time::sleep(Duration::from_millis(200)).await;
-352 let mut found_relay_urls = BTreeSet::new();
-353 let items = address_lookup
-354 .resolve(secret.public())
-355 .unwrap()
-356 .collect::<Vec<_>>()
-357 .await;
-358 for item in items.into_iter().flatten() {
-359 for url in item.relay_urls() {
-360 found_relay_urls.insert(url.clone());
-361 }
+345 // publish is fire and forget, so we have no way to wait until it is done.
+346 tokio::time::timeout(Duration::from_secs(30), async move {
+347 loop {
+348 tokio::time::sleep(Duration::from_millis(200)).await;
+349 let mut found_relay_urls = BTreeSet::new();
+350 let items = address_lookup
+351 .resolve(secret.public())
+352 .unwrap()
+353 .collect::<Vec<_>>()
+354 .await;
+355 for item in items.into_iter().flatten() {
+356 for url in item.relay_urls() {
+357 found_relay_urls.insert(url.clone());
+358 }
+359 }
+360 if found_relay_urls.contains(&relay_url) {
+361 break;
362 }
-363 if found_relay_urls.contains(&relay_url) {
-364 break;
-365 }
-366 }
-367 })
-368 .await
-369 .expect("timeout, relay_url not found on DHT");
-370 Ok(())
-371 }
-372}
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Trait Implementations§
Source§impl Debug for DecodingError
impl Debug for DecodingError
Source§impl Display for DecodingError
impl Display for DecodingError
Source§impl Error for DecodingError
impl Error for DecodingError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
Source§impl From<DecodingError> for AnyError
impl From<DecodingError> for AnyError
Source§fn from(value: DecodingError) -> AnyError
fn from(value: DecodingError) -> AnyError
Source§impl From<DecodingError> for ParseError
impl From<DecodingError> for ParseError
Source§fn from(source: DecodingError) -> Self
fn from(source: DecodingError) -> Self
Source§impl StackError for DecodingError
impl StackError for DecodingError
Source§fn as_std(&self) -> &(dyn Error + Send + Sync + 'static)
fn as_std(&self) -> &(dyn Error + Send + Sync + 'static)
Source§fn into_std(self: Box<Self>) -> Box<dyn Error + Send + Sync>
fn into_std(self: Box<Self>) -> Box<dyn Error + Send + Sync>
Source§fn fmt_message(&self, f: &mut Formatter<'_>) -> Result
fn fmt_message(&self, f: &mut Formatter<'_>) -> Result
Source§fn is_transparent(&self) -> bool
fn is_transparent(&self) -> bool
Auto Trait Implementations§
impl Freeze for DecodingError
impl RefUnwindSafe for DecodingError
impl Send for DecodingError
impl Sync for DecodingError
impl Unpin for DecodingError
impl UnwindSafe for DecodingError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
diff --git a/pr/4026/docs/iroh_dns/index.html b/pr/4026/docs/iroh_dns/index.html
index e276c05581..f8d2fcb8a6 100644
--- a/pr/4026/docs/iroh_dns/index.html
+++ b/pr/4026/docs/iroh_dns/index.html
@@ -1,5 +1,5 @@
iroh_dns - Rust Crate iroh_dns
Expand description
DNS-based endpoint discovery for iroh.
This crate contains the core types for publishing and resolving iroh endpoint
information via DNS, using the pkarr signed packet format.
-Modules§
- attrs
- Support for handling DNS resource records for dialing by [
EndpointId]. - pkarr
- Pkarr signed packet encoding.
Enums§
Traits§
- Endpoint
IdExt - Extension methods for [
EndpointId] to encode to and decode from z-base-32,
+
Modules§
- attrs
- Support for handling DNS resource records for dialing by
EndpointId. - pkarr
- Pkarr signed packet encoding.
Enums§
Traits§
- Endpoint
IdExt - Extension methods for
EndpointId to encode to and decode from z-base-32,
which is the encoding used by pkarr domain names.
\ No newline at end of file
diff --git a/pr/4026/docs/iroh_dns/pkarr/struct.SignedPacket.html b/pr/4026/docs/iroh_dns/pkarr/struct.SignedPacket.html
index 4d719bcc57..651c5a897c 100644
--- a/pr/4026/docs/iroh_dns/pkarr/struct.SignedPacket.html
+++ b/pr/4026/docs/iroh_dns/pkarr/struct.SignedPacket.html
@@ -3,7 +3,7 @@
The DNS packet must be at most 1000 bytes. Total max size is 1104 bytes.
impl<T> BorrowMut<T> for Twhere
diff --git a/pr/4026/docs/iroh_dns/index.html b/pr/4026/docs/iroh_dns/index.html
index e276c05581..f8d2fcb8a6 100644
--- a/pr/4026/docs/iroh_dns/index.html
+++ b/pr/4026/docs/iroh_dns/index.html
@@ -1,5 +1,5 @@
iroh_dns - Rust Crate iroh_dns
Expand description
DNS-based endpoint discovery for iroh.
This crate contains the core types for publishing and resolving iroh endpoint
information via DNS, using the pkarr signed packet format.
-Modules§
- attrs
- Support for handling DNS resource records for dialing by [
EndpointId]. - pkarr
- Pkarr signed packet encoding.
Enums§
Traits§
- Endpoint
IdExt - Extension methods for [
EndpointId] to encode to and decode from z-base-32,
+
Modules§
- attrs
- Support for handling DNS resource records for dialing by
EndpointId. - pkarr
- Pkarr signed packet encoding.
Enums§
Traits§
- Endpoint
IdExt - Extension methods for
EndpointId to encode to and decode from z-base-32,
which is the encoding used by pkarr domain names.
\ No newline at end of file
diff --git a/pr/4026/docs/iroh_dns/pkarr/struct.SignedPacket.html b/pr/4026/docs/iroh_dns/pkarr/struct.SignedPacket.html
index 4d719bcc57..651c5a897c 100644
--- a/pr/4026/docs/iroh_dns/pkarr/struct.SignedPacket.html
+++ b/pr/4026/docs/iroh_dns/pkarr/struct.SignedPacket.html
@@ -3,7 +3,7 @@
Crate iroh_dns
Expand description
DNS-based endpoint discovery for iroh.
This crate contains the core types for publishing and resolving iroh endpoint information via DNS, using the pkarr signed packet format.
-Modules§
- attrs
- Support for handling DNS resource records for dialing by [
EndpointId]. - pkarr
- Pkarr signed packet encoding.
Enums§
Traits§
- Endpoint
IdExt - Extension methods for [
EndpointId] to encode to and decode from z-base-32, +
Modules§
- attrs
- Support for handling DNS resource records for dialing by
EndpointId. - pkarr
- Pkarr signed packet encoding.
Enums§
Traits§
- Endpoint
IdExt - Extension methods for
EndpointIdto encode to and decode from z-base-32, which is the encoding used by pkarr domain names.
The DNS packet must be at most 1000 bytes. Total max size is 1104 bytes.
Implementations§
Source§impl SignedPacket
impl SignedPacket
Sourcepub fn from_txt_strings(
- secret_key: &SecretKey,
+ secret_key: &SecretKey,
name: &str,
values: impl IntoIterator<Item = impl AsRef<str>>,
ttl: u32,
@@ -11,7 +11,7 @@
This is the common case: multiple TXT values under the same DNS name (e.g. "_iroh").
pub fn from_txt_strings( - secret_key: &SecretKey, + secret_key: &SecretKey, name: &str, values: impl IntoIterator<Item = impl AsRef<str>>, ttl: u32, @@ -11,7 +11,7 @@
This is the common case: multiple TXT values under the same DNS name (e.g. "_iroh").
Sourcepub fn from_bytes(bytes: &[u8]) -> Result<SignedPacket, SignedPacketVerifyError>
pub fn from_bytes(bytes: &[u8]) -> Result<SignedPacket, SignedPacketVerifyError>
Parse and verify a signed packet from its wire representation.
Sourcepub fn from_relay_payload(
- public_key: &PublicKey,
+ public_key: &PublicKey,
payload: &[u8],
) -> Result<SignedPacket, SignedPacketVerifyError>
pub fn from_relay_payload( - public_key: &PublicKey, + public_key: &PublicKey, payload: &[u8], ) -> Result<SignedPacket, SignedPacketVerifyError>
Create from a public key and relay payload (signature + timestamp + dns).
Sourcepub fn from_bytes_unchecked(
@@ -20,8 +20,8 @@
Still validates minimum length and DNS parsing.
pub fn from_bytes_unchecked( @@ -20,8 +20,8 @@
Still validates minimum length and DNS parsing.
Sourcepub fn to_relay_payload(&self) -> Vec<u8> ⓘ
pub fn to_relay_payload(&self) -> Vec<u8> ⓘ
Return the relay payload (everything after the public key).
-Sourcepub fn public_key(&self) -> PublicKey
pub fn public_key(&self) -> PublicKey
Return the public key.
-Sourcepub fn public_key(&self) -> PublicKey
pub fn public_key(&self) -> PublicKey
Return the public key.
+Sourcepub fn encoded_packet(&self) -> &[u8] ⓘ
pub fn encoded_packet(&self) -> &[u8] ⓘ
Return the encoded DNS packet bytes.
Sourcepub fn txt_records(&self, name: &str) -> Vec<String>
pub fn txt_records(&self, name: &str) -> Vec<String>
Iterate over TXT records under a specific DNS name.
diff --git a/pr/4026/docs/iroh_dns/trait.EndpointIdExt.html b/pr/4026/docs/iroh_dns/trait.EndpointIdExt.html index bdd3ab70e4..4ee78decb2 100644 --- a/pr/4026/docs/iroh_dns/trait.EndpointIdExt.html +++ b/pr/4026/docs/iroh_dns/trait.EndpointIdExt.html @@ -1,9 +1,9 @@EndpointIdExt
pub trait EndpointIdExt {
// Required methods
fn to_z32(&self) -> String;
- fn from_z32(s: &str) -> Result<EndpointId, DecodingError>;
-}Expand description
Extension methods for [ Extension methods for EndpointId] to encode to and decode from z-base-32,
+ fn from_z32(s: &str) -> Result<EndpointId, DecodingError>;
+}Expand description
EndpointId to encode to and decode from z-base-32,
which is the encoding used by pkarr domain names.
Required Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl EndpointIdExt for EndpointId
impl EndpointIdExt for EndpointId
Implementors§
Required Methods§
Sourcefn to_z32(&self) -> String
fn to_z32(&self) -> String
Encodes a EndpointId in z-base-32 encoding.
Sourcefn from_z32(s: &str) -> Result<EndpointId, DecodingError>
fn from_z32(s: &str) -> Result<EndpointId, DecodingError>
Parses a EndpointId from z-base-32 encoding.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.