提交 c68d6ea3 编写于 作者: A Alexey Milovidov

Better message when listen_host is IPv6 address and IPv6 is disabled [#METR-21842].

上级 bd74c2bd
......@@ -419,7 +419,11 @@ void DNS::aierror(int code, const std::string& arg)
throw HostNotFoundException(arg);
#endif
default:
throw DNSException("EAI", NumberFormatter::format(code));
#if defined(POCO_HAVE_ADDRINFO)
throw DNSException(gai_strerror(code), NumberFormatter::format(code), code);
#else
throw DNSException("EAI", NumberFormatter::format(code), code);
#endif
}
#endif // POCO_HAVE_IPv6 || defined(POCO_HAVE_ADDRINFO)
}
......
......@@ -2,6 +2,7 @@
#include <Poco/Net/HTTPServerRequest.h>
#include <Poco/Net/DNS.h>
#include <Poco/Net/NetException.h>
#include <Poco/Util/XMLConfiguration.h>
#include <Poco/DirectoryIterator.h>
......@@ -371,7 +372,25 @@ int Server::main(const std::vector<std::string> & args)
http_params->setKeepAliveTimeout(keep_alive_timeout);
/// HTTP
Poco::Net::ServerSocket http_socket(Poco::Net::SocketAddress(listen_host, config().getInt("http_port")));
Poco::Net::SocketAddress http_socket_address;
try
{
http_socket_address = Poco::Net::SocketAddress(listen_host, config().getInt("http_port"));
}
catch (const Poco::Net::DNSException & e)
{
/// Better message when IPv6 is disabled on host.
if (e.code() == EAI_ADDRFAMILY)
{
LOG_ERROR(log, "Cannot resolve listen_host (" << listen_host + "), error: " << e.message() << ". "
"If it is an IPv6 address and your host has disabled IPv6, then consider to specify IPv4 address to listen in <listen_host> element of configuration file. Example: <listen_host>0.0.0.0</listen_host>");
}
throw;
}
Poco::Net::ServerSocket http_socket(http_socket_address);
http_socket.setReceiveTimeout(settings.receive_timeout);
http_socket.setSendTimeout(settings.send_timeout);
Poco::Net::HTTPServer http_server(
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册