From 64dc79656b48bf331ef19b4c2dee20f2531c1af8 Mon Sep 17 00:00:00 2001 From: Aram Peres Date: Sat, 16 Oct 2021 02:57:26 -0400 Subject: [PATCH] Support hostnames for SOURCE_ADDR, endpoint-addr See #7 --- src/config.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/config.rs b/src/config.rs index e8b71a4..2c1a993 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,4 +1,4 @@ -use std::net::{IpAddr, SocketAddr}; +use std::net::{IpAddr, SocketAddr, ToSocketAddrs}; use std::sync::Arc; use anyhow::Context; @@ -98,8 +98,10 @@ impl Config { fn parse_addr(s: Option<&str>) -> anyhow::Result { s.with_context(|| "Missing address")? - .parse::() - .with_context(|| "Invalid address") + .to_socket_addrs() + .with_context(|| "Invalid address")? + .next() + .with_context(|| "Could not lookup address") } fn parse_ip(s: Option<&str>) -> anyhow::Result {