stream_ssl_slave: Fix socket overwrite (#7306)
When a slave had SSL activate for stream and local access it was overwritten the addresses, this PR fixes this problem that was not allowed the stream works 100%
thiagoftsm committed
Nov 14, 2019 at 14:16 UTC
0d985568013377c332a7574fd2935339b583d9d4
4 files changed
+8
-5
collectors/plugins.d/plugins_d.c
+3
-3
@@ -258,17 +258,17 @@ inline size_t pluginsd_process(RRDHOST *host, struct plugind *cd, FILE *fp, int
258
#ifdef ENABLE_HTTPS
259
int normalread = 1;
260
if(netdata_srv_ctx) {
261
- if(host->ssl.conn && !host->ssl.flags) {
261
+ if(host->stream_ssl.conn && !host->stream_ssl.flags) {
262
if(!bytesleft) {
263
r = line;
264
readfrom = tmpbuffer;
265
- bytesleft = pluginsd_update_buffer(readfrom, host->ssl.conn);
265
+ bytesleft = pluginsd_update_buffer(readfrom, host->stream_ssl.conn);
266
if(bytesleft <= 0) {
267
break;
268
}
269
}
270
271
- readfrom = pluginsd_get_from_buffer(line, &bytesleft, readfrom, host->ssl.conn, tmpbuffer);
271
+ readfrom = pluginsd_get_from_buffer(line, &bytesleft, readfrom, host->stream_ssl.conn, tmpbuffer);
272
if(!readfrom) {
273
r = NULL;
274
}
database/rrd.h
+1
@@ -739,6 +739,7 @@ struct rrdhost {
739
740
#ifdef ENABLE_HTTPS
741
struct netdata_ssl ssl; //Structure used to encrypt the connection
742
+ struct netdata_ssl stream_ssl; //Structure used to encrypt the stream
743
#endif
744
745
struct rrdhost *next;
database/rrdhost.c
+2
@@ -150,6 +150,8 @@ RRDHOST *rrdhost_create(const char *hostname,
150
#ifdef ENABLE_HTTPS
151
host->ssl.conn = NULL;
152
host->ssl.flags = NETDATA_SSL_START;
153
+ host->stream_ssl.conn = NULL;
154
+ host->stream_ssl.flags = NETDATA_SSL_START;
155
#endif
156
157
netdata_mutex_init(&host->rrdpush_sender_buffer_mutex);
streaming/rrdpush.c
+2
-2
@@ -1079,8 +1079,8 @@ static int rrdpush_receive(int fd
1079
1080
info("STREAM %s [receive from [%s]:%s]: initializing communication...", host->hostname, client_ip, client_port);
1081
#ifdef ENABLE_HTTPS
1082
- host->ssl.conn = ssl->conn;
1083
- host->ssl.flags = ssl->flags;
1082
+ host->stream_ssl.conn = ssl->conn;
1083
+ host->stream_ssl.flags = ssl->flags;
1084
if(send_timeout(ssl,fd, START_STREAMING_PROMPT, strlen(START_STREAMING_PROMPT), 0, 60) != strlen(START_STREAMING_PROMPT)) {
1085
#else
1086
if(send_timeout(fd, START_STREAMING_PROMPT, strlen(START_STREAMING_PROMPT), 0, 60) != strlen(START_STREAMING_PROMPT)) {