mirror of
				https://github.com/node-red/node-red.git
				synced 2025-03-01 10:36:34 +00:00 
			
		
		
		
	websocket - add proxy support.
This commit is contained in:
		@@ -19,6 +19,8 @@ module.exports = function(RED) {
 | 
			
		||||
    var ws = require("ws");
 | 
			
		||||
    var inspect = require("util").inspect;
 | 
			
		||||
    var url = require("url");
 | 
			
		||||
    var HttpsProxyAgent = require('https-proxy-agent');
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    var serverUpgradeAdded = false;
 | 
			
		||||
    function handleServerUpgrade(request, socket, head) {
 | 
			
		||||
@@ -55,7 +57,28 @@ module.exports = function(RED) {
 | 
			
		||||
 | 
			
		||||
        function startconn() {    // Connect to remote endpoint
 | 
			
		||||
            node.tout = null;
 | 
			
		||||
            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(","); }
 | 
			
		||||
            
 | 
			
		||||
            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);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            var options = {};
 | 
			
		||||
            if (agent) {
 | 
			
		||||
                options.agent = agent;
 | 
			
		||||
            }
 | 
			
		||||
            if (node.tls) {
 | 
			
		||||
                var tlsNode = RED.nodes.getNode(node.tls);
 | 
			
		||||
                if (tlsNode) {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user