Merge remote-tracking branch 'upstream/dev' into fix-mqtt-keep-subscription-4132

This commit is contained in:
Steve-Mcl
2023-05-25 12:07:33 +01:00
40 changed files with 467 additions and 214 deletions

View File

@@ -4,6 +4,7 @@
<label style="width: auto" for="node-input-scope" data-i18n="catch.label.source"></label>
<select id="node-input-scope-select">
<option value="all" data-i18n="catch.scope.all"></option>
<option value="group" data-i18n="catch.scope.group"></option>
<option value="target" data-i18n="catch.scope.selected"></option>
</select>
</div>
@@ -170,6 +171,8 @@
});
if (this.scope === null) {
$("#node-input-scope-select").val("all");
} else if(this.scope === "group"){
$("#node-input-scope-select").val("group");
} else {
$("#node-input-scope-select").val("target");
}
@@ -179,6 +182,8 @@
var scope = $("#node-input-scope-select").val();
if (scope === 'all') {
this.scope = null;
} else if(scope === 'group') {
this.scope = "group";
} else {
$("#node-input-uncaught").prop("checked",false);
this.scope = $("#node-input-catch-target-container-div").treeList('selected').map(function(i) { return i.node.id})

View File

@@ -4,6 +4,7 @@
<label style="width: auto" for="node-input-scope" data-i18n="status.label.source"></label>
<select id="node-input-scope-select">
<option value="all" data-i18n="status.scope.all"></option>
<option value="group" data-i18n="status.scope.group"></option>
<option value="target" data-i18n="status.scope.selected"></option>
</select>
</div>
@@ -157,6 +158,8 @@
});
if (this.scope === null) {
$("#node-input-scope-select").val("all");
} else if(this.scope === "group"){
$("#node-input-scope-select").val("group");
} else {
$("#node-input-scope-select").val("target");
}
@@ -166,6 +169,8 @@
var scope = $("#node-input-scope-select").val();
if (scope === 'all') {
this.scope = null;
} else if(scope === 'group') {
this.scope = "group";
} else {
this.scope = $("#node-input-status-target-container-div").treeList('selected').map(function(i) { return i.node.id})
}

View File

@@ -35,7 +35,11 @@ module.exports = function(RED) {
}
else { node.previous = {}; }
}
var value = RED.util.getMessageProperty(msg,node.property);
var value;
try {
value = RED.util.getMessageProperty(msg,node.property);
}
catch(e) { }
if (value !== undefined) {
var t = "_no_topic";
if (node.septopics) { t = topic || t; }

View File

@@ -14,9 +14,9 @@
* limitations under the License.
**/
module.exports = function(RED) {
module.exports = async function(RED) {
"use strict";
const got = require("got");
const { got } = await import('got')
const {CookieJar} = require("tough-cookie");
const { HttpProxyAgent, HttpsProxyAgent } = require('hpagent');
const FormData = require('form-data');
@@ -210,24 +210,24 @@ in your Node-RED user directory (${RED.settings.userDir}).
// set defaultport, else when using HttpsProxyAgent, it's defaultPort of 443 will be used :(.
// Had to remove this to get http->https redirect to work
// opts.defaultPort = isHttps?443:80;
opts.timeout = node.reqTimeout;
opts.timeout = { request: node.reqTimeout || 5000 };
opts.throwHttpErrors = false;
// TODO: add UI option to auto decompress. Setting to false for 1.x compatibility
opts.decompress = false;
opts.method = method;
opts.retry = 0;
opts.retry = { limit: 0 };
opts.responseType = 'buffer';
opts.maxRedirects = 21;
opts.cookieJar = new CookieJar();
opts.ignoreInvalidCookies = true;
opts.forever = nodeHTTPPersistent;
// opts.forever = nodeHTTPPersistent;
if (msg.requestTimeout !== undefined) {
if (isNaN(msg.requestTimeout)) {
node.warn(RED._("httpin.errors.timeout-isnan"));
} else if (msg.requestTimeout < 1) {
node.warn(RED._("httpin.errors.timeout-isnegative"));
} else {
opts.timeout = msg.requestTimeout;
opts.timeout = { request: msg.requestTimeout };
}
}
const originalHeaderMap = {};
@@ -245,9 +245,12 @@ in your Node-RED user directory (${RED.settings.userDir}).
delete options.headers[h];
}
})
if (node.insecureHTTPParser) {
options.insecureHTTPParser = true
// Setting the property under _unixOptions as pretty
// much the only hack available to get got to apply
// a core http option it doesn't think we should be
// allowed to set
options._unixOptions = { ...options.unixOptions, insecureHTTPParser: true }
}
}
],
@@ -403,15 +406,16 @@ in your Node-RED user directory (${RED.settings.userDir}).
return response
}
const requestUrl = new URL(response.request.requestUrl);
const options = response.request.options;
const options = { headers: {} }
const normalisedHeaders = {};
Object.keys(response.headers).forEach(k => {
normalisedHeaders[k.toLowerCase()] = response.headers[k]
})
if (normalisedHeaders['www-authenticate']) {
let authHeader = buildDigestHeader(digestCreds.user,digestCreds.password, options.method, requestUrl.pathname, normalisedHeaders['www-authenticate'])
let authHeader = buildDigestHeader(digestCreds.user,digestCreds.password, response.request.options.method, requestUrl.pathname, normalisedHeaders['www-authenticate'])
options.headers.Authorization = authHeader;
}
// response.request.options.merge(options)
sentCreds = true;
return retry(options);
}

View File

@@ -33,7 +33,13 @@ module.exports = function(RED) {
parseString(value, options, function (err, result) {
if (err) { done(err); }
else {
value = result;
// TODO: With xml2js@0.5.0, they return an object with
// a null prototype. This could cause unexpected
// issues. So for now, we have to reconstruct
// the object with a proper prototype.
// Once https://github.com/Leonidas-from-XIV/node-xml2js/pull/674
// is merged, we can revisit and hopefully remove this hack
value = fixObj(result)
RED.util.setMessageProperty(msg,node.property,value);
send(msg);
done();
@@ -46,4 +52,18 @@ module.exports = function(RED) {
});
}
RED.nodes.registerType("xml",XMLNode);
function fixObj(obj) {
const res = {}
const keys = Object.keys(obj)
keys.forEach(k => {
if (typeof obj[k] === 'object' && obj[k]) {
res[k] = fixObj(obj[k])
} else {
res[k] = obj[k]
}
})
return res
}
}

View File

@@ -98,6 +98,7 @@
},
"scope": {
"all": "allen Nodes",
"group": "in gleicher Gruppe",
"selected": "ausgewählten Nodes"
}
},
@@ -110,6 +111,7 @@
},
"scope": {
"all": "allen Nodes",
"group": "in gleicher Gruppe",
"selected": "ausgewählten Nodes"
}
},

View File

@@ -103,6 +103,7 @@
},
"scope": {
"all": "all nodes",
"group": "in same group",
"selected": "selected nodes"
}
},
@@ -115,6 +116,7 @@
},
"scope": {
"all": "all nodes",
"group": "in same group",
"selected": "selected nodes"
}
},

View File

@@ -414,6 +414,7 @@
"port": "ポート",
"keepalive": "キープアライブ時間",
"cleansession": "セッションの初期化",
"autoUnsubscribe": "切断時に購読を自動解除",
"cleanstart": "クリーンスタート",
"use-tls": "TLSを使用",
"tls-config": "TLS設定",

View File

@@ -27,8 +27,8 @@
"cronosjs": "1.7.1",
"denque": "2.1.0",
"form-data": "4.0.0",
"fs-extra": "10.1.0",
"got": "11.8.6",
"fs-extra": "11.1.1",
"got": "12.6.0",
"hash-sum": "2.0.0",
"hpagent": "1.2.0",
"https-proxy-agent": "5.0.1",
@@ -44,7 +44,7 @@
"tough-cookie": "4.1.2",
"uuid": "9.0.0",
"ws": "7.5.6",
"xml2js": "0.4.23",
"xml2js": "0.5.0",
"iconv-lite": "0.6.3"
}
}