Skip to content

Commit

Permalink
write_prometheus: don't use AI_ADDRCONFIG for resolving bind address
Browse files Browse the repository at this point in the history
Fixes #4150

write_prometheus uses getaddrinfo to resolve the bind address.
The AI_ADDRCONFIG flag causes getaddrinfo to refuse to resolve
0.0.0.0 when the system has no non-loopback IPv4 addresses configured
and refuse to resolve :: when the system has no non-loopback IPv6 configured.

We want binding to a wildcard address (0.0.0.0 or ::) to always work,
even if the network is down.

To achieve that, don't pass the AI_ADDRCONFIG flag
when resolving a bind address.
  • Loading branch information
Wolf480pl authored and mrunge committed Nov 21, 2023
1 parent cfdfe4a commit 951faba
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/write_prometheus.c
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,7 @@ static int prom_open_socket(int addrfamily) {
struct addrinfo *res;
int status = getaddrinfo(httpd_host, service,
&(struct addrinfo){
.ai_flags = AI_PASSIVE | AI_ADDRCONFIG,
.ai_flags = AI_PASSIVE,
.ai_family = addrfamily,
.ai_socktype = SOCK_STREAM,
},
Expand Down

0 comments on commit 951faba

Please sign in to comment.