From 1240733d6c820398d6d33782b73a74ba87ed75a3 Mon Sep 17 00:00:00 2001 From: Ylian Saint-Hilaire Date: Tue, 3 May 2022 13:43:01 -0700 Subject: [PATCH] Added --bindany option to MeshCMD MicroLMS. --- agents/meshcmd.js | 1 + agents/modules_meshcmd/amt-lme.js | 12 ++++++++++-- agents/modules_meshcore/amt-lme.js | 12 ++++++++++-- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/agents/meshcmd.js b/agents/meshcmd.js index 67fbbd11..e63d0c86 100644 --- a/agents/meshcmd.js +++ b/agents/meshcmd.js @@ -157,6 +157,7 @@ function run(argv) { if ((typeof args.uuidoutput) == 'string' || args.uuidoutput) { settings.uuidoutput = args.uuidoutput; } if ((typeof args.desc) == 'string') { settings.desc = args.desc; } if ((typeof args.dnssuffix) == 'string') { settings.dnssuffix = args.dnssuffix; } + if (args.bindany) { settings.bindany = true; } if (args.emailtoken) { settings.emailtoken = true; } if (args.smstoken) { settings.smstoken = true; } if (args.debug === true) { settings.debuglevel = 1; } diff --git a/agents/modules_meshcmd/amt-lme.js b/agents/modules_meshcmd/amt-lme.js index 31df141b..5f55ed5b 100644 --- a/agents/modules_meshcmd/amt-lme.js +++ b/agents/modules_meshcmd/amt-lme.js @@ -17,6 +17,7 @@ limitations under the License. var MemoryStream = require('MemoryStream'); var lme_id = 0; // Our next channel identifier var lme_port_offset = 0; // Debug: Set this to "-100" to bind to 16892 & 16893 and IN_ADDRANY. This is for LMS debugging. +var lme_bindany = false; // If true, bind to all network interfaces, not just loopback. var xmlParser = null; try { xmlParser = require('amt-xml'); } catch (ex) { } @@ -123,7 +124,10 @@ function lme_heci(options) { if (name == 'connect' && this._LME._connected == true) { func.call(this); } if (name == 'error' && this._LME._error !=null) { func.call(this, this._LME._error); } }); - if ((options != null) && (options.debug == true)) { lme_port_offset = -100; } // LMS debug mode + if (options != null) { + if (options.debug == true) { lme_port_offset = -100; } // LMS debug mode + if (options.bindany == true) { lme_bindany = true; } // Bind to all ports + } var heci = require('heci'); this.INITIAL_RXWINDOW_SIZE = 4096; @@ -189,7 +193,11 @@ function lme_heci(options) { this[name][port].descriptorMetadata = 'amt-lme (port: ' + port + ')'; this[name][port].HECI = this; if (lme_port_offset == 0) { - this[name][port].listen({ port: port, host: '127.0.0.1' }); // Normal mode + if (lme_bindany) { + this[name][port].listen({ port: port }); // Bind all mode + } else { + this[name][port].listen({ port: port, host: '127.0.0.1' }); // Normal mode + } } else { this[name][port].listen({ port: (port + lme_port_offset) }); // Debug mode } diff --git a/agents/modules_meshcore/amt-lme.js b/agents/modules_meshcore/amt-lme.js index 31df141b..5f55ed5b 100644 --- a/agents/modules_meshcore/amt-lme.js +++ b/agents/modules_meshcore/amt-lme.js @@ -17,6 +17,7 @@ limitations under the License. var MemoryStream = require('MemoryStream'); var lme_id = 0; // Our next channel identifier var lme_port_offset = 0; // Debug: Set this to "-100" to bind to 16892 & 16893 and IN_ADDRANY. This is for LMS debugging. +var lme_bindany = false; // If true, bind to all network interfaces, not just loopback. var xmlParser = null; try { xmlParser = require('amt-xml'); } catch (ex) { } @@ -123,7 +124,10 @@ function lme_heci(options) { if (name == 'connect' && this._LME._connected == true) { func.call(this); } if (name == 'error' && this._LME._error !=null) { func.call(this, this._LME._error); } }); - if ((options != null) && (options.debug == true)) { lme_port_offset = -100; } // LMS debug mode + if (options != null) { + if (options.debug == true) { lme_port_offset = -100; } // LMS debug mode + if (options.bindany == true) { lme_bindany = true; } // Bind to all ports + } var heci = require('heci'); this.INITIAL_RXWINDOW_SIZE = 4096; @@ -189,7 +193,11 @@ function lme_heci(options) { this[name][port].descriptorMetadata = 'amt-lme (port: ' + port + ')'; this[name][port].HECI = this; if (lme_port_offset == 0) { - this[name][port].listen({ port: port, host: '127.0.0.1' }); // Normal mode + if (lme_bindany) { + this[name][port].listen({ port: port }); // Bind all mode + } else { + this[name][port].listen({ port: port, host: '127.0.0.1' }); // Normal mode + } } else { this[name][port].listen({ port: (port + lme_port_offset) }); // Debug mode }