@@ -45,7 +45,7 @@ use crate::{
45
45
magicsock:: { self , Handle , NodeIdMappedAddr , OwnAddressSnafu } ,
46
46
metrics:: EndpointMetrics ,
47
47
net_report:: Report ,
48
- tls,
48
+ tls, RelayProtocol ,
49
49
} ;
50
50
51
51
mod rtt_actor;
@@ -732,13 +732,12 @@ impl Endpoint {
732
732
self . add_node_addr ( node_addr. clone ( ) ) ?;
733
733
}
734
734
let node_id = node_addr. node_id ;
735
- let relay_url = node_addr. relay_url . clone ( ) ;
736
735
737
736
// Get the mapped IPv6 address from the magic socket. Quinn will connect to this
738
737
// address. Start discovery for this node if it's enabled and we have no valid or
739
738
// verified address information for this node. Dropping the discovery cancels any
740
739
// still running task.
741
- let ( mapped_addr, direct_addresses , _discovery_drop_guard) = self
740
+ let ( mapped_addr, _discovery_drop_guard) = self
742
741
. get_mapping_addr_and_maybe_start_discovery ( node_addr)
743
742
. await
744
743
. context ( NoAddressSnafu ) ?;
@@ -750,12 +749,7 @@ impl Endpoint {
750
749
// Start connecting via quinn. This will time out after 10 seconds if no reachable
751
750
// address is available.
752
751
753
- debug ! (
754
- ?mapped_addr,
755
- ?direct_addresses,
756
- ?relay_url,
757
- "Attempting connection..."
758
- ) ;
752
+ debug ! ( ?mapped_addr, "Attempting connection..." ) ;
759
753
let client_config = {
760
754
let mut alpn_protocols = vec ! [ alpn. to_vec( ) ] ;
761
755
alpn_protocols. extend ( options. additional_alpns ) ;
@@ -768,27 +762,18 @@ impl Endpoint {
768
762
client_config
769
763
} ;
770
764
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 ( ) ;
777
766
let server_name = & tls:: name:: encode ( node_id) ;
778
767
let connect = self
779
768
. msock
780
769
. endpoint ( )
781
770
. connect_with ( client_config, dest_addr, server_name)
782
771
. context ( QuinnSnafu ) ?;
783
772
784
- let mut paths = direct_addresses;
785
- paths. push ( mapped_addr. private_socket_addr ( ) ) ;
786
-
787
773
Ok ( Connecting {
788
774
inner : connect,
789
775
ep : self . clone ( ) ,
790
776
remote_node_id : Some ( node_id) ,
791
- paths,
792
777
_discovery_drop_guard,
793
778
} )
794
779
}
@@ -1383,20 +1368,18 @@ impl Endpoint {
1383
1368
async fn get_mapping_addr_and_maybe_start_discovery (
1384
1369
& self ,
1385
1370
node_addr : NodeAddr ,
1386
- ) -> Result < ( NodeIdMappedAddr , Vec < SocketAddr > , Option < DiscoveryTask > ) , GetMappingAddressError >
1387
- {
1371
+ ) -> Result < ( NodeIdMappedAddr , Option < DiscoveryTask > ) , GetMappingAddressError > {
1388
1372
let node_id = node_addr. node_id ;
1389
1373
1390
1374
// Only return a mapped addr if we have some way of dialing this node, in other
1391
1375
// words, we have either a relay URL or at least one direct address.
1392
1376
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)
1395
1378
} else {
1396
1379
None
1397
1380
} ;
1398
1381
match addr {
1399
- Some ( ( maddr, direct ) ) => {
1382
+ Some ( maddr) => {
1400
1383
// We have some way of dialing this node, but that doesn't actually mean
1401
1384
// we can actually connect to any of these addresses.
1402
1385
// Therefore, we will invoke the discovery service if we haven't received from the
@@ -1408,7 +1391,7 @@ impl Endpoint {
1408
1391
let discovery = DiscoveryTask :: maybe_start_after_delay ( self , node_id, delay)
1409
1392
. ok ( )
1410
1393
. flatten ( ) ;
1411
- Ok ( ( maddr, direct , discovery) )
1394
+ Ok ( ( maddr, discovery) )
1412
1395
}
1413
1396
1414
1397
None => {
@@ -1423,8 +1406,7 @@ impl Endpoint {
1423
1406
. await
1424
1407
. context ( get_mapping_address_error:: DiscoverSnafu ) ?;
1425
1408
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) ) )
1428
1410
} else {
1429
1411
Err ( get_mapping_address_error:: NoAddressSnafu . build ( ) )
1430
1412
}
@@ -1653,8 +1635,6 @@ pub struct Connecting {
1653
1635
inner : quinn:: Connecting ,
1654
1636
ep : Endpoint ,
1655
1637
remote_node_id : Option < NodeId > ,
1656
- /// Additional paths to open once a connection is created
1657
- paths : Vec < SocketAddr > ,
1658
1638
/// We run discovery as long as we haven't established a connection yet.
1659
1639
#[ debug( "Option<DiscoveryTask>" ) ]
1660
1640
_discovery_drop_guard : Option < DiscoveryTask > ,
@@ -1783,21 +1763,15 @@ impl Future for Connecting {
1783
1763
if let Some ( remote) = * this. remote_node_id {
1784
1764
let weak_handle = conn. inner . weak_handle ( ) ;
1785
1765
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) ;
1792
1769
} else if let Ok ( remote) = conn. remote_node_id ( ) {
1793
1770
let weak_handle = conn. inner . weak_handle ( ) ;
1794
1771
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) ;
1801
1775
} else {
1802
1776
warn ! ( "unable to determine node id for the remote" ) ;
1803
1777
}
@@ -2284,6 +2258,7 @@ mod tests {
2284
2258
} ;
2285
2259
2286
2260
use iroh_base:: { NodeAddr , NodeId , SecretKey } ;
2261
+ use iroh_relay:: http:: Protocol ;
2287
2262
use n0_future:: { task:: AbortOnDropHandle , StreamExt } ;
2288
2263
use n0_snafu:: { Error , Result , ResultExt } ;
2289
2264
use n0_watcher:: Watcher ;
0 commit comments