From 3b9e75634aa06b6df0519e5d44fd6e5281712d09 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Sat, 25 Dec 2021 19:19:19 +0100 Subject: Allow Diplonat to automatically detect it's private IP --- src/consul_actor.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/consul_actor.rs') diff --git a/src/consul_actor.rs b/src/consul_actor.rs index b111f09..61789ca 100644 --- a/src/consul_actor.rs +++ b/src/consul_actor.rs @@ -4,7 +4,7 @@ use anyhow::Result; use log::*; use serde::{Deserialize, Serialize}; use serde_lexpr::{error, from_str}; -use tokio::{sync::watch, time::delay_for}; +use tokio::{sync::watch, time::sleep}; use crate::{consul, messages}; @@ -35,7 +35,7 @@ fn retry_to_time(retries: u32, max_time: Duration) -> Duration { return Duration::from_secs(cmp::min( max_time.as_secs(), 1.2f64.powf(retries as f64) as u64, - )) + )); } fn to_parameters(catalog: &consul::CatalogNode) -> Vec { @@ -51,7 +51,7 @@ fn to_parameters(catalog: &consul::CatalogNode) -> Vec { } } - return r + return r; } fn to_open_ports(params: &Vec) -> messages::PublicExposedPorts { @@ -70,7 +70,7 @@ fn to_open_ports(params: &Vec) -> messages::PublicExposedPorts { } } - return op + return op; } impl ConsulActor { @@ -86,7 +86,7 @@ impl ConsulActor { tx_open_ports: tx, node: node.to_string(), retries: 0, - } + }; } pub async fn listen(&mut self) -> Result<()> { @@ -102,15 +102,15 @@ impl ConsulActor { will_retry_in.as_secs(), e ); - delay_for(will_retry_in).await; - continue + sleep(will_retry_in).await; + continue; } }; self.retries = 0; let msg = to_open_ports(&to_parameters(&catalog)); debug!("Extracted configuration: {:#?}", msg); - self.tx_open_ports.broadcast(msg)?; + self.tx_open_ports.send(msg)?; } } } -- cgit v1.2.3