From 7569f21fcd625ac6678b546cab6cffb7f8470ce4 Mon Sep 17 00:00:00 2001 From: Shriraj Hegde Date: Sat, 9 Dec 2023 20:13:01 +0530 Subject: [PATCH] Support host domain in custom config file If `netip.ParseAddr(host)` returns err, try DNS look up for `host` and return IP address associated. --- internal/configuration/sources/files/wireguardselection.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/configuration/sources/files/wireguardselection.go b/internal/configuration/sources/files/wireguardselection.go index f08f3cc29..9a8119eb9 100644 --- a/internal/configuration/sources/files/wireguardselection.go +++ b/internal/configuration/sources/files/wireguardselection.go @@ -64,7 +64,11 @@ func parseWireguardPeerSection(peerSection *ini.Section, ip, err := netip.ParseAddr(host) if err != nil { - return fmt.Errorf("%w: %w", ErrEndpointHostNotIP, err) + ips, err := net.LookupIP(host) + if err != nil { + return fmt.Errorf("resolving domain: %w", err) + } + ip, _ = netip.ParseAddr(ips[0].String()) } endpointPort, err := port.Validate(portString)