Skip to content

Commit

Permalink
help: input: Correct listen should be a parameter for setting up list…
Browse files Browse the repository at this point in the history
…en address

Before this commit, fluent-bit -J produces the incorrect schema for
listen address for ip.
host should be used for specifing to hostname.
And, listen parameter should be used for setting up for listen address.

This is because the following lines in flb_input.c:
```c
    else if (prop_key_check("listen", k, len) == 0) {
        flb_utils_set_plugin_string_property("listen", &ins->host.listen, tmp);
    }
    else if (prop_key_check("host", k, len) == 0) {
        flb_utils_set_plugin_string_property("host", &ins->host.name, tmp);
    }
```

Set up for listen address and hostname respectively.
And the host member is typed as struct flb_net_host whose definition is:
```c
struct flb_input_instance {
/* snip */
    /*
     * Input network info:
     *
     * An input plugin can be specified just using it shortname or using the
     * complete network address format, e.g:
     *
     *  $ fluent-bit -i cpu -o plugin://hostname:port/uri
     *
     * where:
     *
     *   plugin   = the output plugin shortname
     *   name     = IP address or hostname of the target
     *   port     = target TCP port
     *   uri      = extra information that may be used by the plugin
     */
    struct flb_net_host host;
/* snip */
};
```

Then, the type of struct flb_net_host should be:
```c
/* Defines a host service and it properties */
struct flb_net_host {
    int ipv6;              /* IPv6 required ?        */
    flb_sds_t address;     /* Original address       */
    int port;              /* TCP port               */
    flb_sds_t name;        /* Hostname               */
    flb_sds_t listen;      /* Listen interface       */
    struct flb_uri *uri;   /* Extra URI parameters   */
};
```

So, the usage and generating for host and listen parameters are inverted
and I have to add a host config_map for DNS resolutions.

Signed-off-by: Hiroshi Hatake <[email protected]>
  • Loading branch information
cosmo0920 authored and edsiper committed Jun 13, 2024
1 parent 477f656 commit 72a543e
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/flb_help.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,16 @@ int flb_help_input(struct flb_input_instance *ins, void **out_buf, size_t *out_s
struct mk_list *tls_config;
struct flb_config_map m_input_net_listen = {
.type = FLB_CONFIG_MAP_STR,
.name = "host",
.name = "listen",
.def_value = "0.0.0.0",
.desc = "Listen Address",
};
struct flb_config_map m_input_net_host = {
.type = FLB_CONFIG_MAP_STR,
.name = "host",
.def_value = "localhost",
.desc = "Hostname",
};
struct flb_config_map m_input_net_port = {
.type = FLB_CONFIG_MAP_INT,
.name = "port",
Expand Down Expand Up @@ -243,7 +249,7 @@ int flb_help_input(struct flb_input_instance *ins, void **out_buf, size_t *out_s
options_size = mk_list_size(config_map);

if ((ins->flags & (FLB_INPUT_NET | FLB_INPUT_NET_SERVER)) != 0) {
options_size += 2;
options_size += 3;
}
if (ins->flags & FLB_IO_OPT_TLS) {
tls_config = flb_tls_get_config_map(ins->config);
Expand All @@ -254,6 +260,7 @@ 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) {
pack_config_map_entry(&mp_pck, &m_input_net_listen);
pack_config_map_entry(&mp_pck, &m_input_net_host);
pack_config_map_entry(&mp_pck, &m_input_net_port);
}
if (ins->flags & FLB_IO_OPT_TLS) {
Expand Down

0 comments on commit 72a543e

Please sign in to comment.