@@ -45,7 +45,7 @@ use crate::{
4545 magicsock:: { self , Handle , NodeIdMappedAddr , OwnAddressSnafu } ,
4646 metrics:: EndpointMetrics ,
4747 net_report:: Report ,
48- tls,
48+ tls, RelayProtocol ,
4949} ;
5050
5151mod rtt_actor;
@@ -732,13 +732,12 @@ impl Endpoint {
732732 self . add_node_addr ( node_addr. clone ( ) ) ?;
733733 }
734734 let node_id = node_addr. node_id ;
735- let relay_url = node_addr. relay_url . clone ( ) ;
736735
737736 // Get the mapped IPv6 address from the magic socket. Quinn will connect to this
738737 // address. Start discovery for this node if it's enabled and we have no valid or
739738 // verified address information for this node. Dropping the discovery cancels any
740739 // still running task.
741- let ( mapped_addr, direct_addresses , _discovery_drop_guard) = self
740+ let ( mapped_addr, _discovery_drop_guard) = self
742741 . get_mapping_addr_and_maybe_start_discovery ( node_addr)
743742 . await
744743 . context ( NoAddressSnafu ) ?;
@@ -750,12 +749,7 @@ impl Endpoint {
750749 // Start connecting via quinn. This will time out after 10 seconds if no reachable
751750 // address is available.
752751
753- debug ! (
754- ?mapped_addr,
755- ?direct_addresses,
756- ?relay_url,
757- "Attempting connection..."
758- ) ;
752+ debug ! ( ?mapped_addr, "Attempting connection..." ) ;
759753 let client_config = {
760754 let mut alpn_protocols = vec ! [ alpn. to_vec( ) ] ;
761755 alpn_protocols. extend ( options. additional_alpns ) ;
@@ -768,27 +762,18 @@ impl Endpoint {
768762 client_config
769763 } ;
770764
771- // TODO: race available addresses, this is currently only using the relay addr to connect
772- let dest_addr = if relay_url. is_none ( ) && !direct_addresses. is_empty ( ) {
773- direct_addresses[ 0 ]
774- } else {
775- mapped_addr. private_socket_addr ( )
776- } ;
765+ let dest_addr = mapped_addr. private_socket_addr ( ) ;
777766 let server_name = & tls:: name:: encode ( node_id) ;
778767 let connect = self
779768 . msock
780769 . endpoint ( )
781770 . connect_with ( client_config, dest_addr, server_name)
782771 . context ( QuinnSnafu ) ?;
783772
784- let mut paths = direct_addresses;
785- paths. push ( mapped_addr. private_socket_addr ( ) ) ;
786-
787773 Ok ( Connecting {
788774 inner : connect,
789775 ep : self . clone ( ) ,
790776 remote_node_id : Some ( node_id) ,
791- paths,
792777 _discovery_drop_guard,
793778 } )
794779 }
@@ -1383,20 +1368,18 @@ impl Endpoint {
13831368 async fn get_mapping_addr_and_maybe_start_discovery (
13841369 & self ,
13851370 node_addr : NodeAddr ,
1386- ) -> Result < ( NodeIdMappedAddr , Vec < SocketAddr > , Option < DiscoveryTask > ) , GetMappingAddressError >
1387- {
1371+ ) -> Result < ( NodeIdMappedAddr , Option < DiscoveryTask > ) , GetMappingAddressError > {
13881372 let node_id = node_addr. node_id ;
13891373
13901374 // Only return a mapped addr if we have some way of dialing this node, in other
13911375 // words, we have either a relay URL or at least one direct address.
13921376 let addr = if self . msock . has_send_address ( node_id) {
1393- let maddr = self . msock . get_mapping_addr ( node_id) ;
1394- maddr. map ( |maddr| ( maddr, self . msock . get_direct_addrs ( node_id) ) )
1377+ self . msock . get_mapping_addr ( node_id)
13951378 } else {
13961379 None
13971380 } ;
13981381 match addr {
1399- Some ( ( maddr, direct ) ) => {
1382+ Some ( maddr) => {
14001383 // We have some way of dialing this node, but that doesn't actually mean
14011384 // we can actually connect to any of these addresses.
14021385 // Therefore, we will invoke the discovery service if we haven't received from the
@@ -1408,7 +1391,7 @@ impl Endpoint {
14081391 let discovery = DiscoveryTask :: maybe_start_after_delay ( self , node_id, delay)
14091392 . ok ( )
14101393 . flatten ( ) ;
1411- Ok ( ( maddr, direct , discovery) )
1394+ Ok ( ( maddr, discovery) )
14121395 }
14131396
14141397 None => {
@@ -1423,8 +1406,7 @@ impl Endpoint {
14231406 . await
14241407 . context ( get_mapping_address_error:: DiscoverSnafu ) ?;
14251408 if let Some ( addr) = self . msock . get_mapping_addr ( node_id) {
1426- let direct = self . msock . get_direct_addrs ( node_id) ;
1427- Ok ( ( addr, direct, Some ( discovery) ) )
1409+ Ok ( ( addr, Some ( discovery) ) )
14281410 } else {
14291411 Err ( get_mapping_address_error:: NoAddressSnafu . build ( ) )
14301412 }
@@ -1653,8 +1635,6 @@ pub struct Connecting {
16531635 inner : quinn:: Connecting ,
16541636 ep : Endpoint ,
16551637 remote_node_id : Option < NodeId > ,
1656- /// Additional paths to open once a connection is created
1657- paths : Vec < SocketAddr > ,
16581638 /// We run discovery as long as we haven't established a connection yet.
16591639 #[ debug( "Option<DiscoveryTask>" ) ]
16601640 _discovery_drop_guard : Option < DiscoveryTask > ,
@@ -1783,21 +1763,15 @@ impl Future for Connecting {
17831763 if let Some ( remote) = * this. remote_node_id {
17841764 let weak_handle = conn. inner . weak_handle ( ) ;
17851765 let path_events = conn. inner . path_events ( ) ;
1786- this. ep . msock . register_connection (
1787- remote,
1788- weak_handle,
1789- path_events,
1790- this. paths . clone ( ) ,
1791- ) ;
1766+ this. ep
1767+ . msock
1768+ . register_connection ( remote, weak_handle, path_events) ;
17921769 } else if let Ok ( remote) = conn. remote_node_id ( ) {
17931770 let weak_handle = conn. inner . weak_handle ( ) ;
17941771 let path_events = conn. inner . path_events ( ) ;
1795- this. ep . msock . register_connection (
1796- remote,
1797- weak_handle,
1798- path_events,
1799- this. paths . clone ( ) ,
1800- ) ;
1772+ this. ep
1773+ . msock
1774+ . register_connection ( remote, weak_handle, path_events) ;
18011775 } else {
18021776 warn ! ( "unable to determine node id for the remote" ) ;
18031777 }
@@ -2284,6 +2258,7 @@ mod tests {
22842258 } ;
22852259
22862260 use iroh_base:: { NodeAddr , NodeId , SecretKey } ;
2261+ use iroh_relay:: http:: Protocol ;
22872262 use n0_future:: { task:: AbortOnDropHandle , StreamExt } ;
22882263 use n0_snafu:: { Error , Result , ResultExt } ;
22892264 use n0_watcher:: Watcher ;
0 commit comments