Skip to content

Commit

Permalink
in_forward: Remove debug prints
Browse files Browse the repository at this point in the history
Signed-off-by: Hiroshi Hatake <[email protected]>
  • Loading branch information
cosmo0920 committed Mar 8, 2024
1 parent fd053cb commit 5f15f3f
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 61 deletions.
17 changes: 0 additions & 17 deletions plugins/in_forward/fw_conn.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,8 @@ int fw_conn_event(void *data)

event = &connection->event;

flb_plg_info(ctx->ins, "ctx->handshake_status = %d", conn->handshake_status);
flb_plg_debug(ctx->ins, "[conn_event] conn->helo->nonce = %s", conn->helo->nonce);
flb_plg_debug(ctx->ins, "[conn_event] conn->helo->salt = %s", conn->helo->salt);

if (event->mask & MK_EVENT_READ) {
if (conn->handshake_status == FW_HANDSHAKE_PINGPONG) {
flb_plg_debug(ctx->ins, "[conn_event] conn->helo = %p", conn->helo);
flb_plg_debug(ctx->ins, "[conn_event] conn->helo->nonce = %s", conn->helo->nonce);

ret = fw_prot_secure_forward_handshake(ctx->ins, conn);
if (ret == -1) {
Expand All @@ -65,8 +59,6 @@ int fw_conn_event(void *data)
conn->handshake_status = FW_HANDSHAKE_ESTABLISHED;
}

flb_plg_info(ctx->ins, "[event->mask] ctx->status = %d", conn->handshake_status);

available = (conn->buf_size - conn->buf_len);
if (available < 1) {
if (conn->buf_size >= ctx->buffer_max_size) {
Expand Down Expand Up @@ -155,14 +147,9 @@ struct fw_conn *fw_conn_add(struct flb_connection *connection, struct flb_in_fw_
return NULL;
}

flb_plg_debug(ctx->ins, "helo->nonce = %s", helo->nonce);
flb_plg_debug(ctx->ins, "helo->salt = %s", helo->salt);
conn->handshake_status = FW_HANDSHAKE_PINGPONG;
}

flb_plg_debug(ctx->ins, "helo: helo->nonce = %s", helo->nonce);
flb_plg_debug(ctx->ins, "helo: helo->salt = %s", helo->salt);

conn->connection = connection;
conn->helo = helo;

Expand All @@ -188,10 +175,6 @@ struct fw_conn *fw_conn_add(struct flb_connection *connection, struct flb_in_fw_
conn->buf_size = ctx->buffer_chunk_size;
conn->in = ctx->ins;

flb_plg_debug(ctx->ins, "helo: conn->helo = %p", conn->helo);
flb_plg_debug(ctx->ins, "helo: conn->helo->nonce = %s", conn->helo->nonce);
flb_plg_debug(ctx->ins, "helo: conn->helo->salt = %s", conn->helo->salt);

/* Register instance into the event loop */
ret = mk_event_add(flb_engine_evl_get(),
connection->fd,
Expand Down
44 changes: 0 additions & 44 deletions plugins/in_forward/fw_prot.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,6 @@ int flb_secure_forward_set_helo(struct flb_input_instance *in,
}
helo->nonce = tmp;
helo->nonce_len = FLB_IN_FW_NONCE_SIZE;
flb_plg_debug(in, "set_helo: nonce = %s", helo->nonce);
flb_plg_debug(in, "set_helo: nonce_size = %d", o.via.str.size);
o = root.via.array.ptr[1];

tmp = flb_sds_create_len(o.via.str.ptr, o.via.str.size);
Expand All @@ -260,8 +258,6 @@ int flb_secure_forward_set_helo(struct flb_input_instance *in,
}
helo->salt = tmp;
helo->salt_len = FLB_IN_FW_SALT_SIZE;
flb_plg_debug(in, "set_helo: salt = %s", helo->salt);
flb_plg_debug(in, "set_helo: salt_size = %d", o.via.str.size);

msgpack_unpacked_destroy(&result);
msgpack_sbuffer_destroy(&mp_sbuf);
Expand Down Expand Up @@ -330,13 +326,8 @@ static int send_helo(struct flb_input_instance *in, struct flb_connection *conne
result = 0;
}

flb_plg_debug(in, "send_helo: nonce = %s", nonce);
flb_plg_debug(in, "send_helo: salt = %s", user_auth_salt);

result = flb_secure_forward_set_helo(in, helo, nonce, user_auth_salt);

flb_plg_debug(in, "send_helo: helo = %p", helo);

return result;
}

Expand Down Expand Up @@ -374,9 +365,6 @@ static int flb_secure_forward_hash_shared_key(struct flb_input_instance *ins,
data_entries[0] = (unsigned char *) shared_key_salt;
length_entries[0] = flb_sds_len(shared_key_salt);

flb_plg_info(ins, "[hash_digest] shared_key_salt = %s", shared_key_salt);
flb_plg_info(ins, "[hash_digest] shared_key_salt_len = %zd", flb_sds_len(shared_key_salt));

data_entries[1] = (unsigned char *) hostname;
length_entries[1] = hostname_len;

Expand Down Expand Up @@ -423,22 +411,14 @@ static int flb_secure_forward_hash_digest(struct flb_input_instance *ins,
data_entries[0] = (unsigned char *) shared_key_salt;
length_entries[0] = flb_sds_len(shared_key_salt);

flb_plg_info(ins, "[hash_digest] shared_key_salt = %s", shared_key_salt);
flb_plg_info(ins, "[hash_digest] shared_key_salt_len = %zd", flb_sds_len(shared_key_salt));

data_entries[1] = (unsigned char *) ctx->self_hostname;
length_entries[1] = strlen(ctx->self_hostname);

flb_plg_info(ins, "[hash_digest] ctx->self_hostname = %s", ctx->self_hostname);

data_entries[2] = (unsigned char *) conn->helo->nonce;
length_entries[2] = FLB_IN_FW_NONCE_SIZE; /* always 16 bytes. */

flb_plg_info(ins, "[hash_digest] conn->helo->nonce = %s", conn->helo->nonce);

data_entries[3] = (unsigned char *) ctx->shared_key;
length_entries[3] = strlen(ctx->shared_key);
flb_plg_info(ins, "[hash_digest] ctx->shared_key = %s", ctx->shared_key);

result = flb_hash_simple_batch(FLB_HASH_SHA512,
4,
Expand Down Expand Up @@ -562,13 +542,6 @@ static int check_ping(struct flb_input_instance *ins,
return -1;
}

flb_plg_debug(ins, "[check_ping] conn->helo = %p", conn->helo);
flb_plg_debug(ins, "[check_ping] conn->helo->nonce = %s", conn->helo->nonce);
flb_plg_debug(ins, "[check_ping] hostname = %s\nshared_key_salt = %s\nshared_key_digest = %s",
hostname, shared_key_salt, shared_key_digest);

flb_plg_debug(ins, "[check_ping] \nserverside = %s\nshared_key_digest = %s", serverside, shared_key_digest);

if (strncmp(serverside, shared_key_digest, shared_key_digest_len) != 0) {
flb_plg_error(ins, "shared_key mismatch");
flb_free(serverside);
Expand Down Expand Up @@ -632,8 +605,6 @@ static int send_pong(struct flb_input_instance *in,
msgpack_pack_str(&mp_pck, 128);
msgpack_pack_str_body(&mp_pck, shared_key_digest_hex, 128);

flb_plg_info(in, "[send_pong] shared_key_digest_hex = %s", shared_key_digest_hex);

bytes = flb_io_net_write(conn->connection,
(void *) mp_sbuf.data,
mp_sbuf.size,
Expand Down Expand Up @@ -1026,9 +997,6 @@ int fw_prot_secure_forward_handshake_start(struct flb_input_instance *ins,
return -1;
}

flb_plg_debug(ins, "protocol: nonce = %s", helo->nonce);
flb_plg_debug(ins, "protocol: salt = %s", helo->salt);

return 0;
}

Expand All @@ -1054,23 +1022,11 @@ int fw_prot_secure_forward_handshake(struct flb_input_instance *ins,
goto error;
}

/* if (conn->helo->nonce != NULL) { */
/* flb_sds_destroy(conn->helo->nonce); */
/* } */
/* if (conn->helo->salt != NULL) { */
/* flb_sds_destroy(conn->helo->salt); */
/* } */
flb_sds_destroy(shared_key_salt);

return 0;

error:
if (conn->helo->nonce != NULL) {
flb_sds_destroy(conn->helo->nonce);
}
if (conn->helo->salt != NULL) {
flb_sds_destroy(conn->helo->salt);
}
if (shared_key_salt != NULL) {
flb_sds_destroy(shared_key_salt);
}
Expand Down

0 comments on commit 5f15f3f

Please sign in to comment.