Commit 1fa5852f authored by Tatsuhiro Tsujikawa's avatar Tatsuhiro Tsujikawa

nghttpx: Treat '*' in <HOST> parameter of --frontend as wildcard explicitly

It seems that specifyig '*' to node parameter in getaddrinfo() is
treated as specifying NULL, but it is not documented.  So rather than
relying on this feature, we explicitly treat '*' as "wildcard" address
and specify NULL to node parameter in getaddrinfo().

Now '*,3000' is a default value of --frontend option.  Specyfing '*'
binds all addresses including both IPv4 and IPv6.
parent ebf0e4d7
...@@ -131,7 +131,6 @@ void evlistener_errorcb(evconnlistener *listener, void *ptr) ...@@ -131,7 +131,6 @@ void evlistener_errorcb(evconnlistener *listener, void *ptr)
namespace { namespace {
evconnlistener* create_evlistener(ListenHandler *handler, int family) evconnlistener* create_evlistener(ListenHandler *handler, int family)
{ {
// TODO Listen both IPv4 and IPv6
addrinfo hints; addrinfo hints;
int fd = -1; int fd = -1;
int r; int r;
...@@ -145,8 +144,10 @@ evconnlistener* create_evlistener(ListenHandler *handler, int family) ...@@ -145,8 +144,10 @@ evconnlistener* create_evlistener(ListenHandler *handler, int family)
hints.ai_flags |= AI_ADDRCONFIG; hints.ai_flags |= AI_ADDRCONFIG;
#endif // AI_ADDRCONFIG #endif // AI_ADDRCONFIG
auto node = strcmp("*", get_config()->host) == 0 ? NULL : get_config()->host;
addrinfo *res, *rp; addrinfo *res, *rp;
r = getaddrinfo(get_config()->host, service.c_str(), &hints, &res); r = getaddrinfo(node, service.c_str(), &hints, &res);
if(r != 0) { if(r != 0) {
if(LOG_ENABLED(INFO)) { if(LOG_ENABLED(INFO)) {
LOG(INFO) << "Unable to get IPv" << (family == AF_INET ? "4" : "6") LOG(INFO) << "Unable to get IPv" << (family == AF_INET ? "4" : "6")
...@@ -346,7 +347,7 @@ void fill_default_config() ...@@ -346,7 +347,7 @@ void fill_default_config()
mod_config()->daemon = false; mod_config()->daemon = false;
mod_config()->server_name = "nghttpx nghttp2/" NGHTTP2_VERSION; mod_config()->server_name = "nghttpx nghttp2/" NGHTTP2_VERSION;
set_config_str(&mod_config()->host, "0.0.0.0"); set_config_str(&mod_config()->host, "*");
mod_config()->port = 3000; mod_config()->port = 3000;
mod_config()->private_key_file = 0; mod_config()->private_key_file = 0;
mod_config()->private_key_passwd = 0; mod_config()->private_key_passwd = 0;
...@@ -499,7 +500,9 @@ Connections: ...@@ -499,7 +500,9 @@ Connections:
<< get_config()->downstream_host << "," << get_config()->downstream_host << ","
<< get_config()->downstream_port << R"(' << get_config()->downstream_port << R"('
-f, --frontend=<HOST,PORT> -f, --frontend=<HOST,PORT>
Set frontend host and port. Set frontend host and port. If <HOST> is '*', it
assumes all addresses including both IPv4 and
IPv6.
Default: ')" Default: ')"
<< get_config()->host << "," << get_config()->port << R"(' << get_config()->host << "," << get_config()->port << R"('
--backlog=<NUM> Set listen backlog size. If -1 is given, --backlog=<NUM> Set listen backlog size. If -1 is given,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment