Added --bindany option to MeshCMD MicroLMS.

Ylian Saint-Hilaire committed May 3, 2022 at 13:43 UTC 1240733d6c820398d6d33782b73a74ba87ed75a3
3 files changed +21 -4
agents/meshcmd.js
+1
@@ -157,6 +157,7 @@ function run(argv) {
157 if ((typeof args.uuidoutput) == 'string' || args.uuidoutput) { settings.uuidoutput = args.uuidoutput; }
158 if ((typeof args.desc) == 'string') { settings.desc = args.desc; }
159 if ((typeof args.dnssuffix) == 'string') { settings.dnssuffix = args.dnssuffix; }
160 + if (args.bindany) { settings.bindany = true; }
161 if (args.emailtoken) { settings.emailtoken = true; }
162 if (args.smstoken) { settings.smstoken = true; }
163 if (args.debug === true) { settings.debuglevel = 1; }
agents/modules_meshcmd/amt-lme.js
+10 -2
@@ -17,6 +17,7 @@ limitations under the License.
17 var MemoryStream = require('MemoryStream');
18 var lme_id = 0; // Our next channel identifier
19 var lme_port_offset = 0; // Debug: Set this to "-100" to bind to 16892 & 16893 and IN_ADDRANY. This is for LMS debugging.
20 +var lme_bindany = false; // If true, bind to all network interfaces, not just loopback.
21 var xmlParser = null;
22 try { xmlParser = require('amt-xml'); } catch (ex) { }
23
@@ -123,7 +124,10 @@ function lme_heci(options) {
124 if (name == 'connect' && this._LME._connected == true) { func.call(this); }
125 if (name == 'error' && this._LME._error !=null) { func.call(this, this._LME._error); }
126 });
126 - if ((options != null) && (options.debug == true)) { lme_port_offset = -100; } // LMS debug mode
127 + if (options != null) {
128 + if (options.debug == true) { lme_port_offset = -100; } // LMS debug mode
129 + if (options.bindany == true) { lme_bindany = true; } // Bind to all ports
130 + }
131
132 var heci = require('heci');
133 this.INITIAL_RXWINDOW_SIZE = 4096;
@@ -189,7 +193,11 @@ function lme_heci(options) {
193 this[name][port].descriptorMetadata = 'amt-lme (port: ' + port + ')';
194 this[name][port].HECI = this;
195 if (lme_port_offset == 0) {
192 - this[name][port].listen({ port: port, host: '127.0.0.1' }); // Normal mode
196 + if (lme_bindany) {
197 + this[name][port].listen({ port: port }); // Bind all mode
198 + } else {
199 + this[name][port].listen({ port: port, host: '127.0.0.1' }); // Normal mode
200 + }
201 } else {
202 this[name][port].listen({ port: (port + lme_port_offset) }); // Debug mode
203 }
agents/modules_meshcore/amt-lme.js
+10 -2
@@ -17,6 +17,7 @@ limitations under the License.
17 var MemoryStream = require('MemoryStream');
18 var lme_id = 0; // Our next channel identifier
19 var lme_port_offset = 0; // Debug: Set this to "-100" to bind to 16892 & 16893 and IN_ADDRANY. This is for LMS debugging.
20 +var lme_bindany = false; // If true, bind to all network interfaces, not just loopback.
21 var xmlParser = null;
22 try { xmlParser = require('amt-xml'); } catch (ex) { }
23
@@ -123,7 +124,10 @@ function lme_heci(options) {
124 if (name == 'connect' && this._LME._connected == true) { func.call(this); }
125 if (name == 'error' && this._LME._error !=null) { func.call(this, this._LME._error); }
126 });
126 - if ((options != null) && (options.debug == true)) { lme_port_offset = -100; } // LMS debug mode
127 + if (options != null) {
128 + if (options.debug == true) { lme_port_offset = -100; } // LMS debug mode
129 + if (options.bindany == true) { lme_bindany = true; } // Bind to all ports
130 + }
131
132 var heci = require('heci');
133 this.INITIAL_RXWINDOW_SIZE = 4096;
@@ -189,7 +193,11 @@ function lme_heci(options) {
193 this[name][port].descriptorMetadata = 'amt-lme (port: ' + port + ')';
194 this[name][port].HECI = this;
195 if (lme_port_offset == 0) {
192 - this[name][port].listen({ port: port, host: '127.0.0.1' }); // Normal mode
196 + if (lme_bindany) {
197 + this[name][port].listen({ port: port }); // Bind all mode
198 + } else {
199 + this[name][port].listen({ port: port, host: '127.0.0.1' }); // Normal mode
200 + }
201 } else {
202 this[name][port].listen({ port: (port + lme_port_offset) }); // Debug mode
203 }