net/ToString: append port only if it is non-zero
This commit is contained in:
		| @@ -72,20 +72,24 @@ ToString(SocketAddress address) noexcept | ||||
| 	if (ret != 0) | ||||
| 		return "unknown"; | ||||
|  | ||||
| 	if (serv[0] != 0 && (serv[0] != '0' || serv[1] != 0)) { | ||||
| #ifdef HAVE_IPV6 | ||||
| 	if (std::strchr(host, ':') != nullptr) { | ||||
| 		std::string result("["); | ||||
| 		result.append(host); | ||||
| 		result.append("]:"); | ||||
| 		if (std::strchr(host, ':') != nullptr) { | ||||
| 			std::string result("["); | ||||
| 			result.append(host); | ||||
| 			result.append("]:"); | ||||
| 			result.append(serv); | ||||
| 			return result; | ||||
| 		} | ||||
| #endif | ||||
|  | ||||
| 		std::string result(host); | ||||
| 		result.push_back(':'); | ||||
| 		result.append(serv); | ||||
| 		return result; | ||||
| 	} | ||||
| #endif | ||||
|  | ||||
| 	std::string result(host); | ||||
| 	result.push_back(':'); | ||||
| 	result.append(serv); | ||||
| 	return result; | ||||
| 	return host; | ||||
| } | ||||
|  | ||||
| std::string | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Max Kellermann
					Max Kellermann