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.
This commit is contained in:
parent
ebf0e4d787
commit
1fa5852f8f
11
src/shrpx.cc
11
src/shrpx.cc
|
@ -131,7 +131,6 @@ void evlistener_errorcb(evconnlistener *listener, void *ptr)
|
|||
namespace {
|
||||
evconnlistener* create_evlistener(ListenHandler *handler, int family)
|
||||
{
|
||||
// TODO Listen both IPv4 and IPv6
|
||||
addrinfo hints;
|
||||
int fd = -1;
|
||||
int r;
|
||||
|
@ -145,8 +144,10 @@ evconnlistener* create_evlistener(ListenHandler *handler, int family)
|
|||
hints.ai_flags |= AI_ADDRCONFIG;
|
||||
#endif // AI_ADDRCONFIG
|
||||
|
||||
auto node = strcmp("*", get_config()->host) == 0 ? NULL : get_config()->host;
|
||||
|
||||
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(LOG_ENABLED(INFO)) {
|
||||
LOG(INFO) << "Unable to get IPv" << (family == AF_INET ? "4" : "6")
|
||||
|
@ -346,7 +347,7 @@ void fill_default_config()
|
|||
mod_config()->daemon = false;
|
||||
|
||||
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()->private_key_file = 0;
|
||||
mod_config()->private_key_passwd = 0;
|
||||
|
@ -499,7 +500,9 @@ Connections:
|
|||
<< get_config()->downstream_host << ","
|
||||
<< get_config()->downstream_port << R"('
|
||||
-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: ')"
|
||||
<< get_config()->host << "," << get_config()->port << R"('
|
||||
--backlog=<NUM> Set listen backlog size. If -1 is given,
|
||||
|
|
Loading…
Reference in New Issue