forked from coolaj86/goldilocks.js
		
	added ability to detect config changes to the socks5 module
This commit is contained in:
		
							parent
							
								
									5534ba2ef1
								
							
						
					
					
						commit
						c637671c78
					
				@ -63,15 +63,28 @@ module.exports.create = function (deps, config) {
 | 
			
		||||
    });
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (config.socks5 && config.socks5.enabled) {
 | 
			
		||||
    start(config.socks5.port).catch(function (err) {
 | 
			
		||||
      console.error('failed to start Socks5 proxy', err);
 | 
			
		||||
    });
 | 
			
		||||
  var configEnabled = false;
 | 
			
		||||
  function updateConf() {
 | 
			
		||||
    var wanted = config.socks5 && config.socks5.enabled;
 | 
			
		||||
 | 
			
		||||
    if (configEnabled && !wanted) {
 | 
			
		||||
      stop().catch(function (err) {
 | 
			
		||||
        console.error('failed to stop socks5 proxy on config change', err);
 | 
			
		||||
      });
 | 
			
		||||
      configEnabled = false;
 | 
			
		||||
    }
 | 
			
		||||
    if (wanted && !configEnabled) {
 | 
			
		||||
      start(config.socks5.port).catch(function (err) {
 | 
			
		||||
        console.error('failed to start Socks5 proxy', err);
 | 
			
		||||
      });
 | 
			
		||||
      configEnabled = true;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  return {
 | 
			
		||||
    curState: curState
 | 
			
		||||
  , start: start
 | 
			
		||||
  , stop: stop
 | 
			
		||||
    curState
 | 
			
		||||
  , start
 | 
			
		||||
  , stop
 | 
			
		||||
  , updateConf
 | 
			
		||||
  };
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user