mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Merge pull request #2987 from node-red/clean-ids
Change node id generation to give fixed length values without '.'
This commit is contained in:
@@ -314,7 +314,7 @@ module.exports = function(RED) {
|
||||
}
|
||||
|
||||
// Build options for passing to the MQTT.js API
|
||||
this.options.clientId = this.clientid || 'mqtt_' + (1+Math.random()*4294967295).toString(16);
|
||||
this.options.clientId = this.clientid || 'mqtt_' + RED.util.generateId();
|
||||
this.options.username = this.username;
|
||||
this.options.password = this.password;
|
||||
this.options.keepalive = this.keepalive;
|
||||
|
@@ -62,14 +62,14 @@ module.exports = function(RED) {
|
||||
if (process.env.HTTP_PROXY) { prox = process.env.HTTP_PROXY; }
|
||||
if (process.env.no_proxy) { noprox = process.env.no_proxy.split(","); }
|
||||
if (process.env.NO_PROXY) { noprox = process.env.NO_PROXY.split(","); }
|
||||
|
||||
|
||||
var noproxy = false;
|
||||
if (noprox) {
|
||||
for (var i in noprox) {
|
||||
if (node.path.indexOf(noprox[i].trim()) !== -1) { noproxy=true; }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var agent = undefined;
|
||||
if (prox && !noproxy) {
|
||||
agent = new HttpsProxyAgent(prox);
|
||||
@@ -92,7 +92,7 @@ module.exports = function(RED) {
|
||||
}
|
||||
|
||||
function handleConnection(/*socket*/socket) {
|
||||
var id = (1+Math.random()*4294967295).toString(16);
|
||||
var id = RED.util.generateId();
|
||||
if (node.isServer) {
|
||||
node._clients[id] = socket;
|
||||
node.emit('opened',{count:Object.keys(node._clients).length,id:id});
|
||||
|
@@ -69,7 +69,7 @@ module.exports = function(RED) {
|
||||
var setupTcpClient = function() {
|
||||
node.log(RED._("tcpin.status.connecting",{host:node.host,port:node.port}));
|
||||
node.status({fill:"grey",shape:"dot",text:"common.status.connecting"});
|
||||
var id = (1+Math.random()*4294967295).toString(16);
|
||||
var id = RED.util.generateId();
|
||||
client = net.connect(node.port, node.host, function() {
|
||||
buffer = (node.datatype == 'buffer') ? Buffer.alloc(0) : "";
|
||||
node.connected = true;
|
||||
@@ -153,7 +153,7 @@ module.exports = function(RED) {
|
||||
var server = net.createServer(function (socket) {
|
||||
socket.setKeepAlive(true,120000);
|
||||
if (socketTimeout !== null) { socket.setTimeout(socketTimeout); }
|
||||
var id = (1+Math.random()*4294967295).toString(16);
|
||||
var id = RED.util.generateId();
|
||||
var fromi;
|
||||
var fromp;
|
||||
connectionPool[id] = socket;
|
||||
|
Reference in New Issue
Block a user