aboutsummaryrefslogtreecommitdiff
path: root/src/diplonat.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2023-04-05 09:47:58 +0200
committerAlex Auvolat <alex@adnab.me>2023-04-05 09:47:58 +0200
commitc356c4d1c471acd9d2f7e1dcfd3a432442177b48 (patch)
tree66f12a24e7a486457d1b907b1e268efd631eab8c /src/diplonat.rs
parentf410230240b270ec01cfbf0002cbe9d3849eb03b (diff)
downloaddiplonat-c356c4d1c471acd9d2f7e1dcfd3a432442177b48.tar.gz
diplonat-c356c4d1c471acd9d2f7e1dcfd3a432442177b48.zip
IPv6-only mode
Diffstat (limited to 'src/diplonat.rs')
-rw-r--r--src/diplonat.rs34
1 files changed, 26 insertions, 8 deletions
diff --git a/src/diplonat.rs b/src/diplonat.rs
index a66836a..a94a6f8 100644
--- a/src/diplonat.rs
+++ b/src/diplonat.rs
@@ -9,7 +9,7 @@ use crate::{
pub struct Diplonat {
consul: ConsulActor,
firewall: FirewallActor,
- igd: IgdActor,
+ igd: Option<IgdActor>,
stun: StunActor,
}
@@ -20,16 +20,26 @@ impl Diplonat {
let ca = ConsulActor::new(&rt_cfg.consul, &rt_cfg.consul.node_name);
- let fw = FirewallActor::new(rt_cfg.firewall.refresh_time, &ca.rx_open_ports).await?;
-
- let ia = IgdActor::new(
- rt_cfg.igd.private_ip,
- rt_cfg.igd.refresh_time,
- rt_cfg.igd.expiration_time,
+ let fw = FirewallActor::new(
+ rt_cfg.firewall.ipv6_only,
+ rt_cfg.firewall.refresh_time,
&ca.rx_open_ports,
)
.await?;
+ let ia = match rt_cfg.igd {
+ Some(igdc) => Some(
+ IgdActor::new(
+ igdc.private_ip,
+ igdc.refresh_time,
+ igdc.expiration_time,
+ &ca.rx_open_ports,
+ )
+ .await?,
+ ),
+ None => None,
+ };
+
let sa = StunActor::new(&rt_cfg.consul, &rt_cfg.stun, &rt_cfg.consul.node_name);
let ctx = Self {
@@ -43,9 +53,17 @@ impl Diplonat {
}
pub async fn listen(&mut self) -> Result<()> {
+ let igd_opt = &mut self.igd;
+
try_join!(
self.consul.listen(),
- self.igd.listen(),
+ async {
+ if let Some(igd) = igd_opt {
+ igd.listen().await
+ } else {
+ Ok(())
+ }
+ },
self.firewall.listen(),
self.stun.listen(),
)?;