aboutsummaryrefslogtreecommitdiff
path: root/src/consul_actor.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2023-04-04 18:46:14 +0200
committerAlex Auvolat <alex@adnab.me>2023-04-04 18:46:14 +0200
commit615f926618471998f85ee184b378b1128340367b (patch)
treebe9b5d5da3e844460a533bea9fefd452892a7f32 /src/consul_actor.rs
parente64be9e8816b9bd5d3d787d1d5d57d460ae37569 (diff)
downloaddiplonat-615f926618471998f85ee184b378b1128340367b.tar.gz
diplonat-615f926618471998f85ee184b378b1128340367b.zip
Add STUN actor that saves autodiscovered IPv4/IPv6 to Consul
Diffstat (limited to 'src/consul_actor.rs')
-rw-r--r--src/consul_actor.rs19
1 files changed, 11 insertions, 8 deletions
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<u16>),
- udp_port(HashSet<u16>),
+ #[serde(rename = "tcp_port")]
+ TcpPort(HashSet<u16>),
+ #[serde(rename = "udp_port")]
+ UdpPort(HashSet<u16>),
}
#[derive(Serialize, Deserialize, Debug)]
pub enum DiplonatConsul {
- diplonat(Vec<DiplonatParameter>),
+ #[serde(rename = "diplonat")]
+ Diplonat(Vec<DiplonatParameter>),
}
pub struct ConsulActor {
@@ -42,8 +45,8 @@ fn retry_to_time(retries: u32, max_time: Duration) -> Duration {
fn to_parameters(catalog: &consul::CatalogNode) -> Vec<DiplonatConsul> {
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<DiplonatConsul> = from_str(tag);
match diplo_conf {
Ok(conf) => r.push(conf),
@@ -62,11 +65,11 @@ fn to_open_ports(params: &Vec<DiplonatConsul>) -> 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),
};
}
}