From 34b1341a61675a7fd8c9078a4d22556323b6ee92 Mon Sep 17 00:00:00 2001 From: ale <ale@incal.net> Date: Sat, 21 Nov 2015 13:19:37 +0000 Subject: [PATCH] resolve hostnames passed in IPList flags --- util/flag.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/util/flag.go b/util/flag.go index d3c4c9e5..d736d0e4 100644 --- a/util/flag.go +++ b/util/flag.go @@ -18,11 +18,17 @@ func (l *ipList) String() string { } func (l *ipList) Set(value string) error { - ip := net.ParseIP(value) - if ip == nil { - return fmt.Errorf("Unable to parse IP address \"%s\"", value) + if ip := net.ParseIP(value); ip != nil { + *l = append(*l, ip) + return nil } - *l = append(*l, ip) + + // Value is not an IP address, try to resolve it. + ips, err := net.LookupIP(value) + if err != nil { + return fmt.Errorf("Unable to parse IP address \"%s\": %v", value, err) + } + *l = append(*l, ips...) return nil } -- GitLab