Browse Source

Merge pull request #17971 from narqo/simplify-addr-formating

Simplify final address formatting in parser.ParseTCPAddr
Antonio Murdaca 9 years ago
parent
commit
1448cd3ec2
1 changed files with 1 additions and 5 deletions
  1. 1 5
      pkg/parsers/parsers.go

+ 1 - 5
pkg/parsers/parsers.go

@@ -107,11 +107,7 @@ func ParseTCPAddr(tryAddr string, defaultAddr string) (string, error) {
 		return "", fmt.Errorf("Invalid bind address format: %s", tryAddr)
 		return "", fmt.Errorf("Invalid bind address format: %s", tryAddr)
 	}
 	}
 
 
-	if net.ParseIP(host).To4() == nil && strings.Contains(host, ":") {
-		// This is either an ipv6 address
-		host = "[" + host + "]"
-	}
-	return fmt.Sprintf("tcp://%s:%d%s", host, p, u.Path), nil
+	return fmt.Sprintf("tcp://%s%s", net.JoinHostPort(host, port), u.Path), nil
 }
 }
 
 
 // ParseRepositoryTag gets a repos name and returns the right reposName + tag|digest
 // ParseRepositoryTag gets a repos name and returns the right reposName + tag|digest