Browse Source

Merge pull request #7659 from gyuho/aaa

pkg/transport: remove port in Certificate.IPAddresses
Gyu-Ho Lee 8 years ago
parent
commit
43f795a485
1 changed files with 3 additions and 3 deletions
  1. 3 3
      pkg/transport/listener.go

+ 3 - 3
pkg/transport/listener.go

@@ -27,7 +27,6 @@ import (
 	"net"
 	"os"
 	"path/filepath"
-	"strings"
 	"time"
 
 	"github.com/coreos/etcd/pkg/tlsutil"
@@ -118,10 +117,11 @@ func SelfCert(dirpath string, hosts []string) (info TLSInfo, err error) {
 	}
 
 	for _, host := range hosts {
-		if ip := net.ParseIP(host); ip != nil {
+		h, _, _ := net.SplitHostPort(host)
+		if ip := net.ParseIP(h); ip != nil {
 			tmpl.IPAddresses = append(tmpl.IPAddresses, ip)
 		} else {
-			tmpl.DNSNames = append(tmpl.DNSNames, strings.Split(host, ":")[0])
+			tmpl.DNSNames = append(tmpl.DNSNames, h)
 		}
 	}