Selaa lähdekoodia

Merge pull request #6412 from heyitsanthony/revert-domain-listener

embed: warn on domain name in listener
Anthony Romano 9 vuotta sitten
vanhempi
commit
c6bfdb909b
2 muutettua tiedostoa jossa 7 lisäystä ja 8 poistoa
  1. 7 2
      embed/config.go
  2. 0 6
      integration/embed_test.go

+ 7 - 2
embed/config.go

@@ -356,19 +356,24 @@ func (cfg Config) IsDefaultHost() (string, error) {
 }
 
 // checkBindURLs returns an error if any URL uses a domain name.
+// TODO: return error in 3.2.0
 func checkBindURLs(urls []url.URL) error {
 	for _, url := range urls {
 		if url.Scheme == "unix" || url.Scheme == "unixs" {
 			continue
 		}
-		host := strings.Split(url.Host, ":")[0]
+		host, _, err := net.SplitHostPort(url.Host)
+		if err != nil {
+			return err
+		}
 		if host == "localhost" {
 			// special case for local address
 			// TODO: support /etc/hosts ?
 			continue
 		}
 		if net.ParseIP(host) == nil {
-			return fmt.Errorf("expected IP in URL for binding (%s)", url.String())
+			err := fmt.Errorf("expected IP in URL for binding (%s)", url.String())
+			plog.Warning(err)
 		}
 	}
 	return nil

+ 0 - 6
integration/embed_test.go

@@ -40,8 +40,6 @@ func TestEmbedEtcd(t *testing.T) {
 		{wpeers: 1, wclients: 1},
 		{wpeers: 2, wclients: 1},
 		{wpeers: 1, wclients: 2},
-		{werr: "expected IP"},
-		{werr: "expected IP"},
 	}
 
 	urls := newEmbedURLs(10)
@@ -60,10 +58,6 @@ func TestEmbedEtcd(t *testing.T) {
 	setupEmbedCfg(&tests[5].cfg, []url.URL{urls[4]}, []url.URL{urls[5], urls[6]})
 	setupEmbedCfg(&tests[6].cfg, []url.URL{urls[7], urls[8]}, []url.URL{urls[9]})
 
-	dnsURL, _ := url.Parse("http://whatever.test:12345")
-	tests[7].cfg.LCUrls = []url.URL{*dnsURL}
-	tests[8].cfg.LPUrls = []url.URL{*dnsURL}
-
 	dir := path.Join(os.TempDir(), fmt.Sprintf("embed-etcd"))
 	os.RemoveAll(dir)
 	defer os.RemoveAll(dir)