Skip to content

Commit

Permalink
network: added ipv6 dns result priorization option
Browse files Browse the repository at this point in the history
Signed-off-by: nvima <[email protected]>
  • Loading branch information
nvima authored and edsiper committed Jan 14, 2024
1 parent 1ca5136 commit d941fd4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
3 changes: 3 additions & 0 deletions include/fluent-bit/flb_network.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ struct flb_net_setup {
/* prioritize ipv4 results when trying to establish a connection*/
int dns_prefer_ipv4;

/* prioritize ipv6 results when trying to establish a connection*/
int dns_prefer_ipv6;

/* maximum number of allowed active TCP connections */
int max_worker_connections;
};
Expand Down
19 changes: 18 additions & 1 deletion src/flb_network.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ void flb_net_setup_init(struct flb_net_setup *net)
net->dns_mode = NULL;
net->dns_resolver = NULL;
net->dns_prefer_ipv4 = FLB_FALSE;
net->dns_prefer_ipv6 = FLB_FALSE;
net->keepalive = FLB_TRUE;
net->keepalive_idle_timeout = 30;
net->keepalive_max_recycle = 0;
Expand Down Expand Up @@ -1268,7 +1269,23 @@ flb_sockfd_t flb_net_tcp_connect(const char *host, unsigned long port,
sorted_res = flb_net_sort_addrinfo_list(res, AF_INET);

if (sorted_res == NULL) {
flb_debug("[net] error sorting getaddrinfo results");
flb_debug("[net] error sorting ipv4 getaddrinfo results");

if (use_async_dns) {
flb_net_free_translated_addrinfo(res);
}
else {
freeaddrinfo(res);
}

return -1;
}
}
else if (u_conn->net->dns_prefer_ipv6) {
sorted_res = flb_net_sort_addrinfo_list(res, AF_INET6);

if (sorted_res == NULL) {
flb_debug("[net] error sorting ipv6 getaddrinfo results");

if (use_async_dns) {
flb_net_free_translated_addrinfo(res);
Expand Down

0 comments on commit d941fd4

Please sign in to comment.