From d1c42262d6ae9524c7a2cbde05deff25498f66bc Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Wed, 12 Apr 2017 20:48:43 +0100 Subject: [PATCH 1/5] Ensure all nodes have access to global context Fixes #1230 --- red/runtime/nodes/Node.js | 2 +- red/runtime/nodes/context.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/red/runtime/nodes/Node.js b/red/runtime/nodes/Node.js index 090bf171d..1ecfe5727 100644 --- a/red/runtime/nodes/Node.js +++ b/red/runtime/nodes/Node.js @@ -65,7 +65,7 @@ Node.prototype.updateWires = function(wires) { } Node.prototype.context = function() { if (!this._context) { - this._context = context.get(this._alias||this.id,this.z); + this._context = context.get(this._alias||this.id,this.z); } return this._context; } diff --git a/red/runtime/nodes/context.js b/red/runtime/nodes/context.js index 014653560..e89ac07ae 100644 --- a/red/runtime/nodes/context.js +++ b/red/runtime/nodes/context.js @@ -44,9 +44,9 @@ function getContext(localId,flowId) { var newContext = createContext(contextId); if (flowId) { newContext.flow = getContext(flowId); - if (globalContext) { - newContext.global = globalContext; - } + } + if (globalContext) { + newContext.global = globalContext; } contexts[contextId] = newContext; return newContext; From e574f4516fd9599bf0cda6fbd8e29693c605a103 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nathana=C3=ABl=20L=C3=A9caud=C3=A9?= Date: Tue, 18 Apr 2017 11:03:16 -0400 Subject: [PATCH 2/5] Update 31-tcpin.js (#1235) TCP-IN: Add check to see if object exists, fixes issue #1222 --- nodes/core/io/31-tcpin.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/nodes/core/io/31-tcpin.js b/nodes/core/io/31-tcpin.js index 4a9650802..776ce942a 100644 --- a/nodes/core/io/31-tcpin.js +++ b/nodes/core/io/31-tcpin.js @@ -461,8 +461,10 @@ module.exports = function(RED) { } } else if (node.splitc === 0) { - clients[connection_id].msg.payload = data; - node.send(clients[connection_id].msg); + if (clients[connection_id]) { + clients[connection_id].msg.payload = data; + node.send(clients[connection_id].msg); + } } else { for (var j = 0; j < data.length; j++ ) { From b756a8edef78280bcfe6010cc5ea3147ba69c78e Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Thu, 20 Apr 2017 12:22:36 +0100 Subject: [PATCH 3/5] Make tcp send msg more consistent to close #1236 --- nodes/core/io/31-tcpin.js | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/nodes/core/io/31-tcpin.js b/nodes/core/io/31-tcpin.js index 776ce942a..8fa30095c 100644 --- a/nodes/core/io/31-tcpin.js +++ b/nodes/core/io/31-tcpin.js @@ -63,7 +63,7 @@ module.exports = function(RED) { if ((node.datatype) === "utf8" && node.newline !== "") { buffer = buffer+data; var parts = buffer.split(node.newline); - for (var i = 0;i 0) { - var msg = {topic:node.topic, payload:buffer}; + var msg = {topic:node.topic, payload:buffer, ip:socket.remoteAddress, port:socket.remotePort}; msg._session = {type:"tcp",id:id}; node.send(msg); } @@ -209,7 +209,6 @@ module.exports = function(RED) { } }); } - } RED.nodes.registerType("tcp in",TcpIn); @@ -456,15 +455,14 @@ module.exports = function(RED) { clients[connection_id].client.on('data', function(data) { if (node.out === "sit") { // if we are staying connected just send the buffer if (clients[connection_id]) { + if (!clients[connection_id].hasOwnProperty("msg")) { clients[connection_id].msg = {}; } clients[connection_id].msg.payload = data; node.send(RED.util.cloneMessage(clients[connection_id].msg)); } } else if (node.splitc === 0) { - if (clients[connection_id]) { - clients[connection_id].msg.payload = data; - node.send(clients[connection_id].msg); - } + clients[connection_id].msg.payload = data; + node.send(clients[connection_id].msg); } else { for (var j = 0; j < data.length; j++ ) { @@ -483,7 +481,8 @@ module.exports = function(RED) { buf.copy(clients[connection_id].msg.payload,0,0,i+1); node.send(clients[connection_id].msg); if (clients[connection_id].client) { - node.status({}); clients[connection_id].client.destroy(); + node.status({}); + clients[connection_id].client.destroy(); delete clients[connection_id]; } } @@ -503,7 +502,8 @@ module.exports = function(RED) { buf.copy(clients[connection_id].msg.payload,0,0,i); node.send(clients[connection_id].msg); if (clients[connection_id].client) { - node.status({}); clients[connection_id].client.destroy(); + node.status({}); + clients[connection_id].client.destroy(); delete clients[connection_id]; } i = 0; @@ -520,7 +520,8 @@ module.exports = function(RED) { buf.copy(clients[connection_id].msg.payload,0,0,i); node.send(clients[connection_id].msg); if (clients[connection_id].client) { - node.status({}); clients[connection_id].client.destroy(); + node.status({}); + clients[connection_id].client.destroy(); delete clients[connection_id]; } i = 0; @@ -594,7 +595,9 @@ module.exports = function(RED) { this.on("close", function(done) { node.done = done; for (var client in clients) { - clients[client].client.destroy(); + if (clients.hasOwnProperty("client")) { + clients[client].client.destroy(); + } } node.status({}); From 40ad4bdbd853603aadab1153b0aecfe83b48b828 Mon Sep 17 00:00:00 2001 From: Cor Bosman Date: Sat, 22 Apr 2017 23:08:09 +0200 Subject: [PATCH 4/5] dont match only part of the node type (#1242) --- editor/js/ui/tab-info.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/editor/js/ui/tab-info.js b/editor/js/ui/tab-info.js index f96fbdbf3..fa13f36bb 100644 --- a/editor/js/ui/tab-info.js +++ b/editor/js/ui/tab-info.js @@ -125,7 +125,7 @@ RED.sidebar.info = (function() { $(table).appendTo(content); $("
").appendTo(content); if (!subflowNode && node.type != "comment") { - var helpText = $("script[data-help-name$='"+node.type+"']").html()||""; + var helpText = $("script[data-help-name='"+node.type+"']").html()||""; addTargetToExternalLinks($('
'+helpText+'
').appendTo(content)); } if (subflowNode) { From 48958f392fee24b2952e26b3fc08d46755755847 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nathana=C3=ABl=20L=C3=A9caud=C3=A9?= Date: Tue, 9 May 2017 17:09:21 -0400 Subject: [PATCH 5/5] TCP In: Fix error in timout callback (#1249) Thanks @natcl --- nodes/core/io/31-tcpin.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/nodes/core/io/31-tcpin.js b/nodes/core/io/31-tcpin.js index 8fa30095c..58f742521 100644 --- a/nodes/core/io/31-tcpin.js +++ b/nodes/core/io/31-tcpin.js @@ -574,14 +574,16 @@ module.exports = function(RED) { clients[connection_id].client.on('timeout',function() { //console.log("TIMEOUT"); - clients[connection_id].connected = false; - node.status({fill:"grey",shape:"dot",text:"tcpin.errors.connect-timeout"}); - //node.warn(RED._("tcpin.errors.connect-timeout")); - if (clients[connection_id] && clients[connection_id].client) { - clients[connection_id].client.connect(port, host, function() { - clients[connection_id].connected = true; - node.status({fill:"green",shape:"dot",text:"common.status.connected"}); - }); + if (clients[connection_id]) { + clients[connection_id].connected = false; + node.status({fill:"grey",shape:"dot",text:"tcpin.errors.connect-timeout"}); + //node.warn(RED._("tcpin.errors.connect-timeout")); + if (clients[connection_id].client) { + clients[connection_id].client.connect(port, host, function() { + clients[connection_id].connected = true; + node.status({fill:"green",shape:"dot",text:"common.status.connected"}); + }); + } } }); }