Skip to content

Commit d9be919

Browse files
edsipercosmo0920
authored andcommitted
output: on upstream_set, honor the new net.proxy_env_ignore value
Signed-off-by: Eduardo Silva <[email protected]>
1 parent d65cbdc commit d9be919

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

src/flb_output.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1592,6 +1592,35 @@ int flb_output_upstream_set(struct flb_upstream *u, struct flb_output_instance *
15921592
/* Set networking options 'net.*' received through instance properties */
15931593
memcpy(&u->base.net, &ins->net_setup, sizeof(struct flb_net_setup));
15941594

1595+
/*
1596+
* If the Upstream was created using a proxy from the environment but the
1597+
* final configuration asks to ignore environment proxy variables, restore
1598+
* the original destination host information.
1599+
*/
1600+
if (u->base.net.proxy_env_ignore == FLB_TRUE && u->proxied_host) {
1601+
flb_free(u->tcp_host);
1602+
u->tcp_host = flb_strdup(u->proxied_host);
1603+
u->tcp_port = u->proxied_port;
1604+
1605+
flb_free(u->proxied_host);
1606+
u->proxied_host = NULL;
1607+
u->proxied_port = 0;
1608+
1609+
/*
1610+
* Credentials are only set when the connection was configured via environment
1611+
* variables. Since we just reverted the upstream to the destination configured
1612+
* by the plugin, drop any credentials that may have been parsed.
1613+
*/
1614+
if (u->proxy_username) {
1615+
flb_free(u->proxy_username);
1616+
u->proxy_username = NULL;
1617+
}
1618+
if (u->proxy_password) {
1619+
flb_free(u->proxy_password);
1620+
u->proxy_password = NULL;
1621+
}
1622+
}
1623+
15951624
return 0;
15961625
}
15971626

0 commit comments

Comments
 (0)