From 615f926618471998f85ee184b378b1128340367b Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Tue, 4 Apr 2023 18:46:14 +0200 Subject: Add STUN actor that saves autodiscovered IPv4/IPv6 to Consul --- src/consul_actor.rs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'src/consul_actor.rs') diff --git a/src/consul_actor.rs b/src/consul_actor.rs index 8b722b6..e4296e7 100644 --- a/src/consul_actor.rs +++ b/src/consul_actor.rs @@ -11,13 +11,16 @@ use crate::{consul, messages}; #[derive(Serialize, Deserialize, Debug)] pub enum DiplonatParameter { - tcp_port(HashSet), - udp_port(HashSet), + #[serde(rename = "tcp_port")] + TcpPort(HashSet), + #[serde(rename = "udp_port")] + UdpPort(HashSet), } #[derive(Serialize, Deserialize, Debug)] pub enum DiplonatConsul { - diplonat(Vec), + #[serde(rename = "diplonat")] + Diplonat(Vec), } pub struct ConsulActor { @@ -42,8 +45,8 @@ fn retry_to_time(retries: u32, max_time: Duration) -> Duration { fn to_parameters(catalog: &consul::CatalogNode) -> Vec { let mut r = Vec::new(); - for (_, service_info) in &catalog.Services { - for tag in &service_info.Tags { + for (_, service_info) in &catalog.services { + for tag in &service_info.tags { let diplo_conf: error::Result = from_str(tag); match diplo_conf { Ok(conf) => r.push(conf), @@ -62,11 +65,11 @@ fn to_open_ports(params: &Vec) -> messages::PublicExposedPorts { }; for conf in params { - let DiplonatConsul::diplonat(c) = conf; + let DiplonatConsul::Diplonat(c) = conf; for parameter in c { match parameter { - DiplonatParameter::tcp_port(p) => op.tcp_ports.extend(p), - DiplonatParameter::udp_port(p) => op.udp_ports.extend(p), + DiplonatParameter::TcpPort(p) => op.tcp_ports.extend(p), + DiplonatParameter::UdpPort(p) => op.udp_ports.extend(p), }; } } -- cgit v1.2.3