mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 09:26:29 +03:00
fix: connect to peers that advertise to you
This commit is contained in:
@@ -122,6 +122,21 @@ impl Iroh {
|
|||||||
Ok(Some(connect_future))
|
Ok(Some(connect_future))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Add gossip peers to realtime channel if it is already active.
|
||||||
|
pub async fn maybe_add_gossip_peers(&self, topic: TopicId, peers: Vec<NodeAddr>) -> Result<()> {
|
||||||
|
if let Some(state) = self.iroh_channels.read().await.get(&topic) {
|
||||||
|
if state.subscribe_loop.is_some() {
|
||||||
|
for peer in &peers {
|
||||||
|
self.endpoint.add_node_addr(peer.clone())?;
|
||||||
|
}
|
||||||
|
self.gossip
|
||||||
|
.join(topic, peers.into_iter().map(|peer| peer.node_id).collect())
|
||||||
|
.await?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
/// Send realtime data to the gossip swarm.
|
/// Send realtime data to the gossip swarm.
|
||||||
pub async fn send_webxdc_realtime_data(
|
pub async fn send_webxdc_realtime_data(
|
||||||
&self,
|
&self,
|
||||||
|
|||||||
@@ -1433,7 +1433,8 @@ async fn add_parts(
|
|||||||
let relay_server = node_addr.relay_url().map(|relay| relay.as_str());
|
let relay_server = node_addr.relay_url().map(|relay| relay.as_str());
|
||||||
let topic = get_iroh_topic_for_msg(context, instance_id).await?;
|
let topic = get_iroh_topic_for_msg(context, instance_id).await?;
|
||||||
iroh_add_peer_for_topic(context, instance_id, topic, node_id, relay_server).await?;
|
iroh_add_peer_for_topic(context, instance_id, topic, node_id, relay_server).await?;
|
||||||
|
let iroh = context.get_or_try_init_peer_channel().await?;
|
||||||
|
iroh.maybe_add_gossip_peers(topic, vec![node_addr]).await?;
|
||||||
chat_id = DC_CHAT_ID_TRASH;
|
chat_id = DC_CHAT_ID_TRASH;
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user