Initialize UpstreamAddress with actual address

Signed-off-by: Jacob Kiers <code@kiers.eu>
This commit is contained in:
Jacob Kiers 2023-08-25 22:51:25 +02:00
parent 7f399af713
commit cd35859c9b
2 changed files with 11 additions and 0 deletions

View File

@ -173,6 +173,10 @@ fn load_config(path: &str) -> Result<ParsedConfig, ConfigError> {
name: name.to_string(), name: name.to_string(),
addr: format!("{}:{}", upstream_host, upsteam_port), addr: format!("{}:{}", upstream_host, upsteam_port),
protocol: upstream_url.scheme().to_string(), protocol: upstream_url.scheme().to_string(),
addresses: Addr(Mutex::new(UpstreamAddress::new(format!(
"{}:{}",
upstream_host, upsteam_port
)))),
..Default::default() ..Default::default()
}), }),
); );

View File

@ -19,6 +19,13 @@ impl Display for UpstreamAddress {
} }
impl UpstreamAddress { impl UpstreamAddress {
pub fn new(address: String) -> Self {
UpstreamAddress {
address,
..Default::default()
}
}
pub fn is_valid(&self) -> bool { pub fn is_valid(&self) -> bool {
if let Some(resolved) = self.resolved_time { if let Some(resolved) = self.resolved_time {
if let Some(ttl) = self.ttl { if let Some(ttl) = self.ttl {