Skip to content

Commit

Permalink
out_forward: Add a new option 'Empty_Shared_Key' (#1874)
Browse files Browse the repository at this point in the history
Fluentd allows to use an empty string "" as a shared key. This means
that the following configuration is perfectly valid in Fluentd.

    <source>
      @type forward
      <security>
        shared_key ""
        self_hostname foo
      </security>
    </source>

The trouble is that Fluent Bit was being unable to connect to such
a Fluentd node, because Fluent Bit's configuration syntax did not
allow to specify an empty string.

This adds a new boolean option 'Empty_Shared_Key' that enables us to
circumvent the limitation, and should make Fluent Bit on par with
Fluentd.

Signed-off-by: Fujimoto Seiji <[email protected]>
  • Loading branch information
Fujimoto Seiji authored and edsiper committed Jan 14, 2020
1 parent bb7c4ad commit 22e297d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
29 changes: 27 additions & 2 deletions plugins/out_forward/forward.c
Original file line number Diff line number Diff line change
Expand Up @@ -628,8 +628,19 @@ static int forward_config_ha(const char *upstream_file,
}

/* Shared key */
tmp = flb_upstream_node_get_property("empty_shared_key", node);
if (tmp && flb_utils_bool(tmp)) {
fc->empty_shared_key = FLB_TRUE;
}
else {
fc->empty_shared_key = FLB_FALSE;
}

tmp = flb_upstream_node_get_property("shared_key", node);
if (tmp) {
if (fc->empty_shared_key == FLB_TRUE) {
fc->shared_key = flb_sds_create("");
}
else if (tmp) {
fc->shared_key = flb_sds_create(tmp);
}
else {
Expand Down Expand Up @@ -755,10 +766,24 @@ static int forward_config_simple(struct flb_forward *ctx,
flb_output_upstream_set(ctx->u, ins);

/* Shared Key */
tmp = flb_output_get_property("empty_shared_key", ins);
if (tmp && flb_utils_bool(tmp)) {
fc->empty_shared_key = FLB_TRUE;
}
else {
fc->empty_shared_key = FLB_FALSE;
}

tmp = flb_output_get_property("shared_key", ins);
if (tmp) {
if (fc->empty_shared_key) {
fc->shared_key = flb_sds_create("");
}
else if (tmp) {
fc->shared_key = flb_sds_create(tmp);
}
else {
fc->shared_key = NULL;
}

tmp = flb_output_get_property("username", ins);
if (tmp) {
Expand Down
1 change: 1 addition & 0 deletions plugins/out_forward/forward.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ struct flb_forward_config {
/* config */
flb_sds_t shared_key; /* shared key */
flb_sds_t self_hostname; /* hotname used in certificate */
int empty_shared_key; /* use an empty string as shared key */
int require_ack_response; /* Require acknowledge for "chunk" */
int send_options; /* send options in messages */

Expand Down

0 comments on commit 22e297d

Please sign in to comment.