From cd35859c9bebf89f9240293bee43e27d6291b77a Mon Sep 17 00:00:00 2001 From: Jacob Kiers Date: Fri, 25 Aug 2023 22:51:25 +0200 Subject: [PATCH] Initialize UpstreamAddress with actual address Signed-off-by: Jacob Kiers --- src/config.rs | 4 ++++ src/servers/upstream_address.rs | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/src/config.rs b/src/config.rs index 64c7699..154318a 100644 --- a/src/config.rs +++ b/src/config.rs @@ -173,6 +173,10 @@ fn load_config(path: &str) -> Result { name: name.to_string(), addr: format!("{}:{}", upstream_host, upsteam_port), protocol: upstream_url.scheme().to_string(), + addresses: Addr(Mutex::new(UpstreamAddress::new(format!( + "{}:{}", + upstream_host, upsteam_port + )))), ..Default::default() }), ); diff --git a/src/servers/upstream_address.rs b/src/servers/upstream_address.rs index 3220a12..4c34dbf 100644 --- a/src/servers/upstream_address.rs +++ b/src/servers/upstream_address.rs @@ -19,6 +19,13 @@ impl Display for UpstreamAddress { } impl UpstreamAddress { + pub fn new(address: String) -> Self { + UpstreamAddress { + address, + ..Default::default() + } + } + pub fn is_valid(&self) -> bool { if let Some(resolved) = self.resolved_time { if let Some(ttl) = self.ttl {