diff --git a/include/fluent-bit/flb_input.h b/include/fluent-bit/flb_input.h index 62d5851e8ab..72bfec5e5a1 100644 --- a/include/fluent-bit/flb_input.h +++ b/include/fluent-bit/flb_input.h @@ -25,6 +25,8 @@ #include #include #include +#include +#include #include #include #include diff --git a/src/flb_help.c b/src/flb_help.c index d93f9680be9..86b016035d3 100644 --- a/src/flb_help.c +++ b/src/flb_help.c @@ -198,7 +198,6 @@ int flb_help_input(struct flb_input_instance *ins, void **out_buf, size_t *out_s msgpack_sbuffer mp_sbuf; msgpack_packer mp_pck; int options_size = 0; - struct mk_list *tls_config; struct flb_config_map m_input_net_listen = { .type = FLB_CONFIG_MAP_STR, .name = "host", @@ -245,10 +244,6 @@ int flb_help_input(struct flb_input_instance *ins, void **out_buf, size_t *out_s if ((ins->flags & (FLB_INPUT_NET | FLB_INPUT_NET_SERVER)) != 0) { options_size += 2; } - if (ins->flags & FLB_IO_OPT_TLS) { - tls_config = flb_tls_get_config_map(ins->config); - options_size += mk_list_size(tls_config); - } msgpack_pack_array(&mp_pck, options_size); @@ -256,14 +251,54 @@ int flb_help_input(struct flb_input_instance *ins, void **out_buf, size_t *out_s pack_config_map_entry(&mp_pck, &m_input_net_listen); pack_config_map_entry(&mp_pck, &m_input_net_port); } - if (ins->flags & FLB_IO_OPT_TLS) { - mk_list_foreach(head, tls_config) { - m = mk_list_entry(head, struct flb_config_map, _head); - pack_config_map_entry(&mp_pck, m); - } - flb_config_map_destroy(tls_config); + + mk_list_foreach(head, config_map) { + m = mk_list_entry(head, struct flb_config_map, _head); + pack_config_map_entry(&mp_pck, m); + } + flb_config_map_destroy(config_map); + } + + if (ins->p->flags & FLB_INPUT_NET_SERVER) { + flb_mp_map_header_append(&mh); + pack_str(&mp_pck, "networking"); + + config_map = flb_downstream_get_config_map(ins->config); + msgpack_pack_array(&mp_pck, mk_list_size(config_map)); + mk_list_foreach(head, config_map) { + m = mk_list_entry(head, struct flb_config_map, _head); + pack_config_map_entry(&mp_pck, m); + } + flb_config_map_destroy(config_map); + } + else if (ins->p->flags & FLB_INPUT_NET) { + flb_mp_map_header_append(&mh); + pack_str(&mp_pck, "networking"); + + config_map = flb_upstream_get_config_map(ins->config); + msgpack_pack_array(&mp_pck, mk_list_size(config_map)); + mk_list_foreach(head, config_map) { + m = mk_list_entry(head, struct flb_config_map, _head); + pack_config_map_entry(&mp_pck, m); } + flb_config_map_destroy(config_map); + } + if (ins->p->flags & (FLB_IO_TLS | FLB_IO_OPT_TLS)) { + flb_mp_map_header_append(&mh); + pack_str(&mp_pck, "network_tls"); + + config_map = flb_tls_get_config_map(ins->config); + msgpack_pack_array(&mp_pck, mk_list_size(config_map)); + + /* Adjust 'tls' default value based on plugin type" */ + m = mk_list_entry_first(config_map, struct flb_config_map, _head); + if (ins->p->flags & FLB_IO_TLS) { + m->value.val.boolean = FLB_TRUE; + } + else if (ins->p->flags & FLB_IO_OPT_TLS) { + m->value.val.boolean = FLB_FALSE; + } mk_list_foreach(head, config_map) { m = mk_list_entry(head, struct flb_config_map, _head); pack_config_map_entry(&mp_pck, m); diff --git a/src/flb_input.c b/src/flb_input.c index a3ae1d75bbd..d160fc6f293 100644 --- a/src/flb_input.c +++ b/src/flb_input.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -853,11 +854,20 @@ int flb_input_net_property_check(struct flb_input_instance *ins, { int ret = 0; - /* Get Downstream net_setup configmap */ - ins->net_config_map = flb_downstream_get_config_map(config); - if (!ins->net_config_map) { - flb_input_instance_destroy(ins); - return -1; + /* Get Downstream or Upstream net_setup configmap */ + if (ins->p->flags & FLB_INPUT_NET_SERVER) { + ins->net_config_map = flb_downstream_get_config_map(config); + if (!ins->net_config_map) { + flb_input_instance_destroy(ins); + return -1; + } + } + else if (ins->p->flags & FLB_INPUT_NET) { + ins->net_config_map = flb_upstream_get_config_map(config); + if (!ins->net_config_map) { + flb_input_instance_destroy(ins); + return -1; + } } /*