Browse Source

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 5 years ago
parent
commit
0d98556801
4 changed files with 8 additions and 5 deletions
  1. 3 3
      collectors/plugins.d/plugins_d.c
  2. 1 0
      database/rrd.h
  3. 2 0
      database/rrdhost.c
  4. 2 2
      streaming/rrdpush.c

+ 3 - 3
collectors/plugins.d/plugins_d.c

@@ -258,17 +258,17 @@ inline size_t pluginsd_process(RRDHOST *host, struct plugind *cd, FILE *fp, int
 #ifdef ENABLE_HTTPS
 #ifdef ENABLE_HTTPS
         int normalread = 1;
         int normalread = 1;
         if(netdata_srv_ctx) {
         if(netdata_srv_ctx) {
-            if(host->ssl.conn && !host->ssl.flags) {
+            if(host->stream_ssl.conn && !host->stream_ssl.flags) {
                 if(!bytesleft) {
                 if(!bytesleft) {
                     r = line;
                     r = line;
                     readfrom = tmpbuffer;
                     readfrom = tmpbuffer;
-                    bytesleft = pluginsd_update_buffer(readfrom, host->ssl.conn);
+                    bytesleft = pluginsd_update_buffer(readfrom, host->stream_ssl.conn);
                     if(bytesleft <= 0) {
                     if(bytesleft <= 0) {
                         break;
                         break;
                     }
                     }
                 }
                 }
 
 
-                readfrom =  pluginsd_get_from_buffer(line, &bytesleft, readfrom, host->ssl.conn, tmpbuffer);
+                readfrom =  pluginsd_get_from_buffer(line, &bytesleft, readfrom, host->stream_ssl.conn, tmpbuffer);
                 if(!readfrom) {
                 if(!readfrom) {
                     r = NULL;
                     r = NULL;
                 }
                 }

+ 1 - 0
database/rrd.h

@@ -739,6 +739,7 @@ struct rrdhost {
 
 
 #ifdef ENABLE_HTTPS
 #ifdef ENABLE_HTTPS
     struct netdata_ssl ssl;                         //Structure used to encrypt the connection
     struct netdata_ssl ssl;                         //Structure used to encrypt the connection
+    struct netdata_ssl stream_ssl;                         //Structure used to encrypt the stream
 #endif
 #endif
 
 
     struct rrdhost *next;
     struct rrdhost *next;

+ 2 - 0
database/rrdhost.c

@@ -150,6 +150,8 @@ RRDHOST *rrdhost_create(const char *hostname,
 #ifdef ENABLE_HTTPS
 #ifdef ENABLE_HTTPS
     host->ssl.conn = NULL;
     host->ssl.conn = NULL;
     host->ssl.flags = NETDATA_SSL_START;
     host->ssl.flags = NETDATA_SSL_START;
+    host->stream_ssl.conn = NULL;
+    host->stream_ssl.flags = NETDATA_SSL_START;
 #endif
 #endif
 
 
     netdata_mutex_init(&host->rrdpush_sender_buffer_mutex);
     netdata_mutex_init(&host->rrdpush_sender_buffer_mutex);

+ 2 - 2
streaming/rrdpush.c

@@ -1079,8 +1079,8 @@ static int rrdpush_receive(int fd
 
 
     info("STREAM %s [receive from [%s]:%s]: initializing communication...", host->hostname, client_ip, client_port);
     info("STREAM %s [receive from [%s]:%s]: initializing communication...", host->hostname, client_ip, client_port);
 #ifdef ENABLE_HTTPS
 #ifdef ENABLE_HTTPS
-    host->ssl.conn = ssl->conn;
-    host->ssl.flags = ssl->flags;
+    host->stream_ssl.conn = ssl->conn;
+    host->stream_ssl.flags = ssl->flags;
     if(send_timeout(ssl,fd, START_STREAMING_PROMPT, strlen(START_STREAMING_PROMPT), 0, 60) != strlen(START_STREAMING_PROMPT)) {
     if(send_timeout(ssl,fd, START_STREAMING_PROMPT, strlen(START_STREAMING_PROMPT), 0, 60) != strlen(START_STREAMING_PROMPT)) {
 #else
 #else
     if(send_timeout(fd, START_STREAMING_PROMPT, strlen(START_STREAMING_PROMPT), 0, 60) != strlen(START_STREAMING_PROMPT)) {
     if(send_timeout(fd, START_STREAMING_PROMPT, strlen(START_STREAMING_PROMPT), 0, 60) != strlen(START_STREAMING_PROMPT)) {