1
0
Fork 0
mirror of https://codeberg.org/icewind/haze.git synced 2026-06-03 17:14:08 +02:00

push: add all local ips as trusted proxies

This commit is contained in:
Robin Appelman 2025-08-07 18:07:25 +02:00
commit 6a043913fa
6 changed files with 116 additions and 45 deletions

View file

@ -36,7 +36,9 @@ use enum_dispatch::enum_dispatch;
use miette::{IntoDiagnostic, Report, Result, WrapErr};
use serde_json::Value;
use std::collections::HashMap;
use std::iter::empty;
use std::net::IpAddr;
use std::str::FromStr;
use std::time::Duration;
use tokio::time::{sleep, timeout};
@ -128,9 +130,13 @@ pub trait ServiceTrait {
.wrap_err("Timeout after 30 seconds")?
}
async fn get_ip(&self, docker: &Docker, cloud_id: &str) -> Result<Option<IpAddr>> {
async fn get_ips(
&self,
docker: &Docker,
cloud_id: &str,
) -> Result<Box<dyn Iterator<Item = IpAddr>>> {
let Some(container) = self.container_name(cloud_id) else {
return Ok(None);
return Ok(Box::new(empty()));
};
docker
.start_container::<String>(&container, None)
@ -151,20 +157,16 @@ pub trait ServiceTrait {
..
})
) {
info.network_settings
let ips: Vec<_> = info
.network_settings
.unwrap()
.networks
.unwrap()
.values()
.next()
.unwrap()
.ip_address
.clone()
.unwrap()
.parse()
.into_diagnostic()
.map(Some)
.wrap_err("Invalid ip address")
.filter_map(|network| network.ip_address.clone())
.filter_map(|address| IpAddr::from_str(&address).ok())
.collect();
Ok(Box::new(ips.into_iter()))
} else {
Err(Report::msg("service not started"))
}