aboutsummaryrefslogtreecommitdiff
path: root/src/acme_actor.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/acme_actor.rs')
-rw-r--r--src/acme_actor.rs45
1 files changed, 24 insertions, 21 deletions
diff --git a/src/acme_actor.rs b/src/acme_actor.rs
index 0d7aec4..cd41b1f 100644
--- a/src/acme_actor.rs
+++ b/src/acme_actor.rs
@@ -11,7 +11,7 @@ use crate::messages;
pub struct AcmeActor {
email: String,
- last_ports: messages::PublicExposedPorts,
+ //last_ports: messages::PublicExposedPorts,
refresh: Duration,
rx_ports: watch::Receiver<messages::PublicExposedPorts>,
@@ -29,7 +29,7 @@ impl AcmeActor {
let ctx = Self {
email: config.email,
- last_ports: messages::PublicExposedPorts::new(),
+ //last_ports: messages::PublicExposedPorts::new(),
refresh: config.refresh_time,
rx_ports: rxp.clone(),
};
@@ -40,29 +40,32 @@ impl AcmeActor {
pub async fn listen(&mut self) -> Result<()> {
let mut interval = time::interval(self.refresh);
loop {
- // 1. Wait for an event
- let new_ports = select! {
- Some(ports) = self.rx_ports.recv() => Some(ports),
- _ = interval.tick() => None,
- else => return Ok(()) // Sender dropped, terminate loop.
- };
-
- // 2. Update last ports if needed
- if let Some(p) = new_ports {
- self.last_ports = p;
- }
-
- // 3. Flush IGD requests
- match self.do_acme().await {
- Ok(()) => debug!("Successfully updated ACME"),
- Err(e) => error!("An error occured while updating ACME. {}", e),
+ select! {
+ Some(ports) = self.rx_ports.recv() => {
+ match self.do_acme(ports).await {
+ Ok(()) => debug!("Successfully updated ACME"),
+ Err(e) => error!("An error occured while updating ACME. {}", e),
+ }
+ },
+ _ = interval.tick() => continue,
+ else => break // Sender dropped, terminate loop.
}
}
+
+ Ok(())
}
- pub async fn do_acme(&self) -> Result<()> {
- debug!("Doing ACME!!!");
- debug!("{:#?}", self.last_ports);
+ pub async fn do_acme(&self, ports: messages::PublicExposedPorts) -> Result<()> {
+ if ports.acme.is_empty() {
+ return Ok(());
+ }
+
+ let primary_url = &ports.acme[0];
+ let secondary_urls = &ports.acme[1..];
+
+ println!("Doing ACME!!!");
+ println!("Primary URL: {:?}", primary_url);
+ println!("Secondary URLs: {:?}", secondary_urls);
Ok(())
}