Skip to content

Commit f5fe772

Browse files
committed
fixes and cleanups after rebase
1 parent e8709fb commit f5fe772

File tree

8 files changed

+24
-53
lines changed

8 files changed

+24
-53
lines changed

iroh-net/src/derp.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ mod codec;
1717
pub mod http;
1818
mod map;
1919
mod metrics;
20-
pub(crate) mod pkarr_announce;
2120
pub(crate) mod server;
2221
pub(crate) mod types;
2322

iroh-net/src/derp/http/client.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,6 @@ impl Client {
389389
/// If there is already an active derp connection, returns the already
390390
/// connected [`crate::derp::client::Client`].
391391
pub async fn connect(&self) -> Result<(DerpClient, usize), ClientError> {
392-
393392
self.send_actor(ActorMessage::Connect).await
394393
}
395394

iroh-net/src/derp/http/server.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,11 @@ impl ServerBuilder {
293293
pub async fn spawn(self) -> Result<Server> {
294294
ensure!(self.secret_key.is_some() || self.derp_override.is_some(), "Must provide a `SecretKey` for the derp server OR pass in an override function for the 'derp' endpoint");
295295
let (derp_handler, derp_server, mesh_clients) = if let Some(secret_key) = self.secret_key {
296-
let server = crate::derp::server::Server::new(secret_key.clone(), self.mesh_key, self.pkarr_relay);
296+
let server = crate::derp::server::Server::new(
297+
secret_key.clone(),
298+
self.mesh_key,
299+
self.pkarr_relay,
300+
);
297301
let packet_fwd = server.packet_forwarder_handler();
298302
let mesh_clients = if let Some(mesh_addrs) = self.mesh_derpers {
299303
ensure!(

iroh-net/src/derp/pkarr_announce.rs

Lines changed: 0 additions & 30 deletions
This file was deleted.

iroh-net/src/discovery/pkarr_relay_publish.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use crate::{discovery::Discovery, dns::node_info::NodeInfo, key::SecretKey, Addr
2424
pub const IROH_TEST_PKARR_RELAY: &str = "https://testdns.iroh.link/pkarr";
2525

2626
/// Default TTL for the _iroh_node TXT record in the pkarr signed packet
27-
const DEFAULT_PKARR_TTL: u32 = 30;
27+
pub const DEFAULT_PKARR_TTL: u32 = 30;
2828

2929
/// Publish node info to a pkarr relay.
3030
#[derive(derive_more::Debug, Clone)]

iroh-net/src/dns/node_info.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,11 @@ impl From<NodeInfo> for AddrInfo {
9393

9494
impl NodeInfo {
9595
/// Create a new [`NodeInfo`] from its parts.
96-
pub fn new(node_id: NodeId, derp_url: Option<Url>) -> Self {
97-
Self { node_id, derp_url }
96+
pub fn new(node_id: NodeId, derp_url: Option<impl Into<Url>>) -> Self {
97+
Self {
98+
node_id,
99+
derp_url: derp_url.map(Into::into),
100+
}
98101
}
99102

100103
/// Convert this node info into a DNS attribute string.

iroh-net/src/magicsock/derp_actor.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,9 @@ use tokio_util::sync::CancellationToken;
1919
use tracing::{debug, info, info_span, trace, warn, Instrument};
2020

2121
use crate::{
22-
derp::{
23-
self, http::ClientError, pkarr_announce::create_signed_packet, DerpUrl, ReceivedMessage,
24-
MAX_PACKET_SIZE,
25-
},
22+
derp::{self, http::ClientError, DerpUrl, ReceivedMessage, MAX_PACKET_SIZE},
23+
discovery::pkarr_relay_publish::DEFAULT_PKARR_TTL,
24+
dns::node_info::NodeInfo,
2625
key::{PublicKey, PUBLIC_KEY_LENGTH},
2726
};
2827

@@ -429,18 +428,20 @@ impl DerpActor {
429428
}
430429

431430
async fn pkarr_announce_to_derp(&self, my_derp: &DerpUrl) -> anyhow::Result<()> {
432-
if let Some(opts) = &self.conn.pkarr_announce {
431+
if let Some(_opts) = &self.conn.pkarr_announce {
433432
let s = self
434433
.active_derp
435434
.iter()
436435
.find_map(|(derp_url, (s, _))| (derp_url == my_derp).then_some(s))
437436
.context("home derp not in list of active derps")?;
438-
let addrs = opts.include_addrs.then(|| {
439-
let local_endpoints = self.conn.endpoints.read();
440-
let local_endpoints = local_endpoints.iter().map(|ep| ep.addr);
441-
local_endpoints.collect()
442-
});
443-
let packet = create_signed_packet(&self.conn.secret_key, my_derp, addrs)?;
437+
// TODO: support direct addrs?
438+
// let addrs = opts.include_addrs.then(|| {
439+
// let local_endpoints = self.conn.endpoints.read();
440+
// let local_endpoints = local_endpoints.iter().map(|ep| ep.addr);
441+
// local_endpoints.collect()
442+
// });
443+
let info = NodeInfo::new(self.conn.secret_key.public(), Some(my_derp.clone()));
444+
let packet = info.to_pkarr_signed_packet(&self.conn.secret_key, DEFAULT_PKARR_TTL)?;
444445
s.send(ActiveDerpMessage::PkarrPublish(packet)).await?;
445446
}
446447
Ok(())

iroh/src/commands/start.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use iroh::{
1616
};
1717
use iroh_net::{
1818
derp::{DerpMap, DerpMode},
19-
discovery::{dns::DnsDiscovery, pkarr_relay_publish, CombinedDiscovery},
19+
discovery::{dns::DnsDiscovery, CombinedDiscovery},
2020
key::SecretKey,
2121
};
2222
use quic_rpc::{transport::quinn::QuinnServerEndpoint, ServiceEndpoint};
@@ -223,11 +223,6 @@ pub(crate) async fn start_node(
223223
let mut discovery = CombinedDiscovery::new();
224224
let dns_discovery = DnsDiscovery::with_n0_testdns();
225225
discovery.add(dns_discovery);
226-
// // TODO: We don't want nodes to self-publish. Remove once publishing over derpers lands.
227-
// let pkarr_publish = pkarr_relay_publish::Publisher::new(
228-
// pkarr_relay_publish::Config::n0_testdns(secret_key.clone()),
229-
// );
230-
// discovery.add(pkarr_publish);
231226

232227
Node::builder(bao_store, doc_store)
233228
.derp_mode(derp_mode)

0 commit comments

Comments
 (0)