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) { |   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) { |       start(config.socks5.port).catch(function (err) { | ||||||
|         console.error('failed to start Socks5 proxy', err); |         console.error('failed to start Socks5 proxy', err); | ||||||
|       }); |       }); | ||||||
|  |       configEnabled = true; | ||||||
|  |     } | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   return { |   return { | ||||||
|     curState: curState |     curState | ||||||
|   , start: start |   , start | ||||||
|   , stop: stop |   , stop | ||||||
|  |   , updateConf | ||||||
|   }; |   }; | ||||||
| }; | }; | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user