diff --git a/pr/3279/docs/iroh/endpoint/enum.DirectAddrType.html b/pr/3279/docs/iroh/endpoint/enum.DirectAddrType.html index a40abdb875..b7a6c0d716 100644 --- a/pr/3279/docs/iroh/endpoint/enum.DirectAddrType.html +++ b/pr/3279/docs/iroh/endpoint/enum.DirectAddrType.html @@ -1,4 +1,4 @@ -DirectAddrType in iroh::endpoint - Rust
iroh::endpoint

Enum DirectAddrType

Source
pub enum DirectAddrType {
+DirectAddrType in iroh::endpoint - Rust
iroh::endpoint

Enum DirectAddrType

Source
pub enum DirectAddrType {
     Unknown,
     Local,
     Stun,
@@ -20,16 +20,16 @@ get a publicly routable direct address.

It is possible to configure iroh to bound to a specific port and independently configure the router to forward this port to the iroh node. This indicates a situation like this, which still uses STUN to discover the public address.

-

Trait Implementations§

Source§

impl Clone for DirectAddrType

Source§

fn clone(&self) -> DirectAddrType

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DirectAddrType

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for DirectAddrType

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Hash for DirectAddrType

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where +

Trait Implementations§

Source§

impl Clone for DirectAddrType

Source§

fn clone(&self) -> DirectAddrType

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DirectAddrType

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for DirectAddrType

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Hash for DirectAddrType

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, - Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for DirectAddrType

Source§

fn cmp(&self, other: &DirectAddrType) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where + Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for DirectAddrType

Source§

fn cmp(&self, other: &DirectAddrType) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where - Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for DirectAddrType

Source§

fn eq(&self, other: &DirectAddrType) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, -and should not be overridden without very good reason.
Source§

impl PartialOrd for DirectAddrType

Source§

fn partial_cmp(&self, other: &DirectAddrType) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the + Self: Sized,
Restrict a value to a certain interval. Read more
Source§

impl PartialEq for DirectAddrType

Source§

fn eq(&self, other: &DirectAddrType) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, +and should not be overridden without very good reason.
Source§

impl PartialOrd for DirectAddrType

Source§

fn partial_cmp(&self, other: &DirectAddrType) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by -the >= operator. Read more
Source§

impl Copy for DirectAddrType

Source§

impl Eq for DirectAddrType

Source§

impl StructuralPartialEq for DirectAddrType

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where +the >= operator. Read more

Source§

impl Copy for DirectAddrType

Source§

impl Eq for DirectAddrType

Source§

impl StructuralPartialEq for DirectAddrType

Auto Trait Implementations§

§

impl Freeze for DirectAddrType

§

impl RefUnwindSafe for DirectAddrType

§

impl Send for DirectAddrType

§

impl Sync for DirectAddrType

§

impl Unpin for DirectAddrType

§

impl UnwindSafe for DirectAddrType

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( diff --git a/pr/3279/docs/iroh/endpoint/struct.DirectAddr.html b/pr/3279/docs/iroh/endpoint/struct.DirectAddr.html index 462613aa48..f388f916a7 100644 --- a/pr/3279/docs/iroh/endpoint/struct.DirectAddr.html +++ b/pr/3279/docs/iroh/endpoint/struct.DirectAddr.html @@ -1,4 +1,4 @@ -DirectAddr in iroh::endpoint - Rust
iroh::endpoint

Struct DirectAddr

Source
pub struct DirectAddr {
+DirectAddr in iroh::endpoint - Rust
iroh::endpoint

Struct DirectAddr

Source
pub struct DirectAddr {
     pub addr: SocketAddr,
     pub typ: DirectAddrType,
 }
Expand description

A direct address on which an iroh-node might be contactable.

@@ -7,16 +7,16 @@ contacted. These can come from various sources depending on the network topolog iroh node, see DirectAddrType for the several kinds of sources.

Fields§

§addr: SocketAddr

The address.

§typ: DirectAddrType

The origin of this direct address.

-

Trait Implementations§

Source§

impl Clone for DirectAddr

Source§

fn clone(&self) -> DirectAddr

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DirectAddr

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Hash for DirectAddr

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where +

Trait Implementations§

Source§

impl Clone for DirectAddr

Source§

fn clone(&self) -> DirectAddr

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DirectAddr

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Hash for DirectAddr

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, - Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for DirectAddr

Source§

fn cmp(&self, other: &DirectAddr) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where + Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for DirectAddr

Source§

fn cmp(&self, other: &DirectAddr) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where - Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for DirectAddr

Source§

fn eq(&self, other: &DirectAddr) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, -and should not be overridden without very good reason.
Source§

impl PartialOrd for DirectAddr

Source§

fn partial_cmp(&self, other: &DirectAddr) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the + Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for DirectAddr

Source§

fn eq(&self, other: &DirectAddr) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, +and should not be overridden without very good reason.
Source§

impl PartialOrd for DirectAddr

Source§

fn partial_cmp(&self, other: &DirectAddr) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by -the >= operator. Read more
Source§

impl Eq for DirectAddr

Source§

impl StructuralPartialEq for DirectAddr

Auto Trait Implementations§

§

impl Freeze for DirectAddr

§

impl RefUnwindSafe for DirectAddr

§

impl Send for DirectAddr

§

impl Sync for DirectAddr

§

impl Unpin for DirectAddr

§

impl UnwindSafe for DirectAddr

Blanket Implementations§

Source§

impl<T> Any for T
where +the >= operator. Read more

Source§

impl Eq for DirectAddr

Source§

impl StructuralPartialEq for DirectAddr

Auto Trait Implementations§

§

impl Freeze for DirectAddr

§

impl RefUnwindSafe for DirectAddr

§

impl Send for DirectAddr

§

impl Sync for DirectAddr

§

impl Unpin for DirectAddr

§

impl UnwindSafe for DirectAddr

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( diff --git a/pr/3279/docs/src/iroh/magicsock.rs.html b/pr/3279/docs/src/iroh/magicsock.rs.html index 6f427f76b3..8529bde0fa 100644 --- a/pr/3279/docs/src/iroh/magicsock.rs.html +++ b/pr/3279/docs/src/iroh/magicsock.rs.html @@ -3562,23 +3562,7 @@ 3561 3562 3563 -3564 -3565 -3566 -3567 -3568 -3569 -3570 -3571 -3572 -3573 -3574 -3575 -3576 -3577 -3578 -3579 -3580

//! Implements a socket that can change its communication path while in use, actively searching for the best way to communicate.
+3564
//! Implements a socket that can change its communication path while in use, actively searching for the best way to communicate.
 //!
 //! Based on tailscale/wgengine/magicsock
 //!
@@ -4592,34 +4576,14 @@
             SendAddr::Relay(url) => transports::Addr::Relay(url, dst_key),
         };
 
-        n0_future::future::poll_fn(move |cx| loop {
-            match self.poll_send_disco_message(cx, &dst, dst_key, &msg) {
-                Poll::Ready(res) => return Poll::Ready(res),
-                Poll::Pending => match self.transports.poll_writable(cx, &dst) {
-                    Poll::Ready(Ok(())) => continue,
-                    Poll::Ready(Err(err)) => return Poll::Ready(Err(err)),
-                    Poll::Pending => return Poll::Pending,
-                },
-            }
-        })
-        .await
-    }
-
-    fn poll_send_disco_message(
-        &self,
-        cx: &mut Context,
-        dst: &transports::Addr,
-        dst_key: PublicKey,
-        msg: &disco::Message,
-    ) -> Poll<io::Result<()>> {
         trace!(?dst, %msg, "send disco message (UDP)");
         if self.is_closed() {
-            return Poll::Ready(Err(io::Error::new(
+            return Err(io::Error::new(
                 io::ErrorKind::NotConnected,
                 "connection closed",
-            )));
+            ));
         }
-        let pkt = self.encode_disco_message(dst_key, msg);
+        let pkt = self.encode_disco_message(dst_key, &msg);
 
         let transmit = transports::Transmit {
             contents: &pkt,
@@ -4627,18 +4591,22 @@
             segment_size: None,
         };
 
-        match self.transports.poll_send(cx, dst, None, &transmit) {
-            Poll::Ready(Ok(())) => {
+        let dst2 = dst.clone();
+        match n0_future::future::poll_fn(move |cx| {
+            self.transports.poll_send(cx, &dst2, None, &transmit)
+        })
+        .await
+        {
+            Ok(()) => {
                 trace!(?dst, %msg, "sent disco message");
                 self.metrics.magicsock.sent_disco_udp.inc();
-                disco_message_sent(msg, &self.metrics.magicsock);
-                Poll::Ready(Ok(()))
+                disco_message_sent(&msg, &self.metrics.magicsock);
+                Ok(())
             }
-            Poll::Ready(Err(err)) => {
+            Err(err) => {
                 warn!(?dst, ?msg, ?err, "failed to send disco message");
-                Poll::Ready(Err(err))
+                Err(err)
             }
-            Poll::Pending => Poll::Pending,
         }
     }
 
diff --git a/pr/3279/docs/src/iroh/magicsock/transports.rs.html b/pr/3279/docs/src/iroh/magicsock/transports.rs.html
index 7f1ddfa299..00da404b04 100644
--- a/pr/3279/docs/src/iroh/magicsock/transports.rs.html
+++ b/pr/3279/docs/src/iroh/magicsock/transports.rs.html
@@ -365,33 +365,7 @@
 364
 365
 366
-367
-368
-369
-370
-371
-372
-373
-374
-375
-376
-377
-378
-379
-380
-381
-382
-383
-384
-385
-386
-387
-388
-389
-390
-391
-392
-393
use std::{
+367
use std::{
     io::{self, IoSliceMut},
     net::{IpAddr, Ipv6Addr, SocketAddr, SocketAddrV6},
     pin::Pin,
@@ -615,32 +589,6 @@
         false
     }
 
-    /// Check if a transport is writable, aka sendable on, for the given `addr`.
-    pub(crate) fn poll_writable(&self, cx: &mut Context, addr: &Addr) -> Poll<io::Result<()>> {
-        // TODO: what about multiple matches?
-        match addr {
-            #[cfg(wasm_browser)]
-            Addr::Ip(..) => Poll::Ready(Err(io::Error::other(
-                "IP based addressing is not supported in the browser",
-            ))),
-            #[cfg(not(wasm_browser))]
-            Addr::Ip(addr) => match self.ip.iter().find(|t| t.is_valid_send_addr(addr)) {
-                Some(t) => t.poll_writable(cx),
-                None => Poll::Pending,
-            },
-            Addr::Relay(url, node_id) => {
-                match self
-                    .relay
-                    .iter()
-                    .find(|t| t.is_valid_send_addr(url, node_id))
-                {
-                    Some(t) => t.poll_writable(cx),
-                    None => Poll::Pending,
-                }
-            }
-        }
-    }
-
     pub(crate) fn create_sender(&self, msock: Arc<MagicSock>) -> UdpSender {
         UdpSender {
             #[cfg(not(wasm_browser))]
diff --git a/pr/3279/docs/src/iroh/magicsock/transports/ip.rs.html b/pr/3279/docs/src/iroh/magicsock/transports/ip.rs.html
index 9527d03712..1f8eb5f507 100644
--- a/pr/3279/docs/src/iroh/magicsock/transports/ip.rs.html
+++ b/pr/3279/docs/src/iroh/magicsock/transports/ip.rs.html
@@ -149,11 +149,7 @@
 148
 149
 150
-151
-152
-153
-154
-155
use std::{
+151
use std::{
     io,
     net::{IpAddr, SocketAddr},
     sync::Arc,
@@ -284,10 +280,6 @@
         }
     }
 
-    pub(super) fn poll_writable(&self, cx: &mut Context) -> Poll<io::Result<()>> {
-        self.socket.poll_writable(cx)
-    }
-
     pub(crate) fn bind_addr(&self) -> SocketAddr {
         self.bind_addr
     }
diff --git a/pr/3279/docs/src/iroh/magicsock/transports/relay.rs.html b/pr/3279/docs/src/iroh/magicsock/transports/relay.rs.html
index c5059a34ef..df21881094 100644
--- a/pr/3279/docs/src/iroh/magicsock/transports/relay.rs.html
+++ b/pr/3279/docs/src/iroh/magicsock/transports/relay.rs.html
@@ -446,28 +446,7 @@
 445
 446
 447
-448
-449
-450
-451
-452
-453
-454
-455
-456
-457
-458
-459
-460
-461
-462
-463
-464
-465
-466
-467
-468
-469
use std::{
+448
use std::{
     io,
     sync::Arc,
     task::{Context, Poll, Waker},
@@ -553,14 +532,12 @@
 
     pub(super) fn poll_send(
         &self,
-        _cx: &mut Context,
+        cx: &mut Context,
         dest_url: RelayUrl,
         dest_node: NodeId,
         transmit: &Transmit<'_>,
     ) -> Poll<io::Result<()>> {
-        // TODO: use context
-
-        let contents = split_packets(transmit);
+        let contents = split_packets(transmit);
 
         let msg = RelaySendItem {
             remote_node: dest_node,
@@ -568,26 +545,7 @@
             datagrams: contents,
         };
 
-        match self.relay_datagram_send_channel.try_send(msg) {
-            Ok(_) => {
-                trace!(node = %dest_node.fmt_short(), relay_url = %dest_url,
-                       "send relay: message queued");
-                Poll::Ready(Ok(()))
-            }
-            Err(mpsc::error::TrySendError::Closed(_)) => {
-                error!(node = %dest_node.fmt_short(), relay_url = %dest_url,
-                      "send relay: message dropped, channel to actor is closed");
-                Poll::Ready(Err(io::Error::new(
-                    io::ErrorKind::ConnectionReset,
-                    "channel to actor is closed",
-                )))
-            }
-            Err(mpsc::error::TrySendError::Full(_)) => {
-                warn!(node = %dest_node.fmt_short(), relay_url = %dest_url,
-                      "send relay: message dropped, channel to actor is full");
-                Poll::Pending
-            }
-        }
+        self.relay_datagram_send_channel.poll_send(cx, msg)
     }
 
     pub(super) fn poll_recv(
@@ -650,10 +608,6 @@
         true
     }
 
-    pub(super) fn poll_writable(&self, cx: &mut Context) -> Poll<io::Result<()>> {
-        self.relay_datagram_send_channel.poll_writable(cx)
-    }
-
     pub(super) fn rebind(&self) -> io::Result<()> {
         self.send_relay_actor(RelayActorMessage::MaybeCloseRelaysOnRebind);
 
@@ -765,30 +719,34 @@
 }
 
 impl RelayDatagramSendChannelSender {
-    fn try_send(
-        &self,
-        item: RelaySendItem,
-    ) -> Result<(), mpsc::error::TrySendError<RelaySendItem>> {
-        self.sender.try_send(item)
-    }
+    fn poll_send(&self, cx: &mut Context, item: RelaySendItem) -> Poll<io::Result<()>> {
+        let dest_node = item.remote_node;
+        let dest_url = item.url.clone();
 
-    pub(super) fn poll_writable(&self, cx: &mut Context) -> Poll<io::Result<()>> {
-        match self.sender.capacity() {
-            0 => {
+        match self.sender.try_send(item) {
+            Ok(_) => {
+                trace!(node = %dest_node.fmt_short(), relay_url = %dest_url,
+                       "send relay: message queued");
+                Poll::Ready(Ok(()))
+            }
+            Err(mpsc::error::TrySendError::Closed(_)) => {
+                error!(node = %dest_node.fmt_short(), relay_url = %dest_url,
+                      "send relay: message dropped, channel to actor is closed");
+                Poll::Ready(Err(io::Error::new(
+                    io::ErrorKind::ConnectionReset,
+                    "channel to actor is closed",
+                )))
+            }
+            Err(mpsc::error::TrySendError::Full(_)) => {
+                warn!(node = %dest_node.fmt_short(), relay_url = %dest_url,
+                      "send relay: message dropped, channel to actor is full");
                 let mut wakers = self.wakers.lock().expect("poisoned");
                 if !wakers.iter().any(|waker| waker.will_wake(cx.waker())) {
                     wakers.push(cx.waker().clone());
                 }
                 drop(wakers);
-                if self.sender.capacity() != 0 {
-                    // We "risk" a spurious wake-up in this case, but rather that
-                    // than potentially skipping a receive.
-                    Poll::Ready(Ok(()))
-                } else {
-                    Poll::Pending
-                }
+                Poll::Pending
             }
-            _ => Poll::Ready(Ok(())),
         }
     }
 }