0
0
mirror of https://github.com/OpenVPN/openvpn3.git synced 2024-09-20 04:02:15 +02:00

URL::Parse: improve support for bracketed hosts such as IPv6 addresses

Signed-off-by: James Yonan <james@openvpn.net>
This commit is contained in:
James Yonan 2021-11-15 08:59:36 -07:00
parent cbb2018b3c
commit 46e7b3e2ff

View File

@ -195,9 +195,19 @@ namespace openvpn {
return (scheme == "http" && port == "80") || (scheme == "https" && port == "443");
}
bool is_bracketed_host() const
{
return host.find_first_of(":/\\") != std::string::npos;
}
std::string bracketed_host() const
{
return '[' + host + ']';
}
std::string to_string() const
{
const bool bracket_host = (host.find_first_of(":/\\") != std::string::npos);
const bool bracket_host = is_bracketed_host();
std::string ret;
ret.reserve(256);