Improved parsing of universal port configuration settings (RIPD-856)

This commit is contained in:
Miguel Portilla
2015-04-13 17:57:22 -04:00
parent 0c134582ca
commit b1f6cb349b
3 changed files with 12 additions and 15 deletions

View File

@@ -585,28 +585,25 @@ parse_Port (ParsedPort& port, Section const& section, std::ostream& log)
port.admin_ip.emplace ();
while (std::getline (ss, ip, ','))
{
beast::IP::Address const addr(
beast::IP::Endpoint::from_string_altform (ip).address ());
if (addr.is_any ())
{
has_any = true;
}
else if (is_unspecified (addr))
auto const addr = beast::IP::Endpoint::from_string_checked (ip);
if (! addr.second)
{
log << "Invalid value '" << ip << "' for key 'admin' in ["
<< section.name() << "]\n";
<< section.name () << "]\n";
throw std::exception ();
}
if (is_unspecified (addr.first))
has_any = true;
if (has_any && ! port.admin_ip->empty ())
{
log << "IP specified with 0.0.0.0 '" << ip <<
log << "IP specified along with 0.0.0.0 '" << ip <<
"' for key 'admin' in [" << section.name () << "]\n";
throw std::exception ();
}
port.admin_ip->emplace_back (addr);
port.admin_ip->emplace_back (addr.first.address ());
}
}
}