mirror of
				https://github.com/node-red/node-red.git
				synced 2025-03-01 10:36:34 +00:00 
			
		
		
		
	mqtt & httprequest: change proxy comparison from null to falsy.
mqtt - add no_proxy support.
This commit is contained in:
		| @@ -111,9 +111,13 @@ module.exports = function(RED) { | ||||
|         if (typeof this.cleansession === 'undefined') { | ||||
|             this.cleansession = true; | ||||
|         } | ||||
|         var prox; | ||||
|         if (process.env.http_proxy != null) { prox = process.env.http_proxy; } | ||||
|         if (process.env.HTTP_PROXY != null) { prox = process.env.HTTP_PROXY; } | ||||
|  | ||||
|         var prox, noprox; | ||||
|         if (process.env.http_proxy) { prox = process.env.http_proxy; } | ||||
|         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(","); } | ||||
|  | ||||
|  | ||||
|         // Create the URL to pass in to the MQTT.js library | ||||
|         if (this.brokerurl === "") { | ||||
| @@ -121,9 +125,15 @@ module.exports = function(RED) { | ||||
|             if (this.broker.indexOf("://") > -1) { | ||||
|                 this.brokerurl = this.broker; | ||||
|                 // Only for ws or wss, check if proxy env var for additional configuration | ||||
|                 if (this.brokerurl.indexOf("wss://") > -1 || this.brokerurl.indexOf("ws://") > -1 ) | ||||
|                 // check if proxy is set in env | ||||
|                     if (prox) { | ||||
|                 if (this.brokerurl.indexOf("wss://") > -1 || this.brokerurl.indexOf("ws://") > -1 ) { | ||||
|                     // check if proxy is set in env | ||||
|                     var noproxy; | ||||
|                     if (noprox) { | ||||
|                         for (var i in noprox) { | ||||
|                             if (this.brokerurl.indexOf(noprox[i].trim()) !== -1) { noproxy=true; } | ||||
|                         } | ||||
|                     } | ||||
|                     if (prox && !noproxy) { | ||||
|                         var parsedUrl = url.parse(this.brokerurl); | ||||
|                         var proxyOpts = url.parse(prox); | ||||
|                         // true for wss | ||||
| @@ -134,6 +144,7 @@ module.exports = function(RED) { | ||||
|                             agent: agent | ||||
|                         } | ||||
|                     } | ||||
|                 } | ||||
|             } else { | ||||
|                 // construct the std mqtt:// url | ||||
|                 if (this.usetls) { | ||||
|   | ||||
| @@ -39,10 +39,10 @@ module.exports = function(RED) { | ||||
|         else { this.reqTimeout = 120000; } | ||||
|  | ||||
|         var prox, noprox; | ||||
|         if (process.env.http_proxy != null) { prox = process.env.http_proxy; } | ||||
|         if (process.env.HTTP_PROXY != null) { prox = process.env.HTTP_PROXY; } | ||||
|         if (process.env.no_proxy != null) { noprox = process.env.no_proxy.split(","); } | ||||
|         if (process.env.NO_PROXY != null) { noprox = process.env.NO_PROXY.split(","); } | ||||
|         if (process.env.http_proxy) { prox = process.env.http_proxy; } | ||||
|         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 proxyConfig = null; | ||||
|         if (n.proxy) { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user