Add validation

This commit is contained in:
Louis Taylor 2018-07-05 14:42:38 +01:00
parent 4804086fdf
commit e35a09bd72
No known key found for this signature in database
GPG Key ID: 8E81A6DAE13E7098

View File

@ -2,6 +2,7 @@ package options
import (
"fmt"
"net"
"time"
"github.com/spf13/pflag"
@ -136,5 +137,17 @@ func (o *ControllerOptions) Validate() error {
default:
return fmt.Errorf("invalid default issuer kind: %v", o.DefaultIssuerKind)
}
for _, server := range o.DNS01Nameservers {
// ensure all servers have a port number
host, _, err := net.SplitHostPort(server)
if err != nil {
return fmt.Errorf("invalid DNS server (%v): %v", err, server)
}
ip := net.ParseIP(host)
if ip == nil {
return fmt.Errorf("invalid IP address: %v", host)
}
}
return nil
}