send auth info
This commit is contained in:
		
							parent
							
								
									7ec69f8d05
								
							
						
					
					
						commit
						b9779715f8
					
				| @ -12,9 +12,10 @@ function timeoutPromise(duration) { | |||||||
|   }); |   }); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| function run(state) { | function _connect(state) { | ||||||
|   // jshint latedef:false
 |   // jshint latedef:false
 | ||||||
|   var activityTimeout = state.activityTimeout || (2*60 - 5)*1000; |   var defaultHttpTimeout = (2 * 60); | ||||||
|  |   var activityTimeout = state.activityTimeout || (defaultHttpTimeout - 5) * 1000; | ||||||
|   var pongTimeout = state.pongTimeout || 10*1000; |   var pongTimeout = state.pongTimeout || 10*1000; | ||||||
|   // Allow the tunnel client to be created with no token. This will prevent the connection from
 |   // Allow the tunnel client to be created with no token. This will prevent the connection from
 | ||||||
|   // being established initialy and allows the caller to use `.append` for the first token so
 |   // being established initialy and allows the caller to use `.append` for the first token so
 | ||||||
| @ -477,19 +478,24 @@ function run(state) { | |||||||
|   }; |   }; | ||||||
| 
 | 
 | ||||||
|   function connect() { |   function connect() { | ||||||
|     if (!tokens.length) { |     var auth; | ||||||
|       console.warn("[Non-fatal Error] No tokens. Nothing to do."); |  | ||||||
|       return; |  | ||||||
|     } |  | ||||||
|     if (wstunneler) { |     if (wstunneler) { | ||||||
|       console.warn('attempted to connect with connection already active'); |       console.warn('attempted to connect with connection already active'); | ||||||
|       return; |       return; | ||||||
|     } |     } | ||||||
|  |     if (tokens.length) { | ||||||
|  |       auth = 'access_token=' + tokens[0]; | ||||||
|  |     } else if (state.config.email) { | ||||||
|  |       auth = 'subject=' + state.config.email; | ||||||
|  |       auth += '&subject_scheme=mailto'; | ||||||
|  |       // TODO create domains list earlier
 | ||||||
|  |       auth += '&scope=' + Object.keys(state.config.servernames || {}).join(','); | ||||||
|  |     } | ||||||
|     timeoutId = null; |     timeoutId = null; | ||||||
|     var machine = Packer.create(packerHandlers); |     var machine = Packer.create(packerHandlers); | ||||||
| 
 | 
 | ||||||
|     console.info("[connect] '" + state.relay + "'"); |     console.info("[connect] '" + state.relay + "'"); | ||||||
|     var tunnelUrl = state.relay.replace(/\/$/, '') + '/?access_token=' + tokens[0]; |     var tunnelUrl = state.relay.replace(/\/$/, '') + '/?' + auth; | ||||||
|     wstunneler = new WebSocket(tunnelUrl, { rejectUnauthorized: !state.insecure }); |     wstunneler = new WebSocket(tunnelUrl, { rejectUnauthorized: !state.insecure }); | ||||||
|     wstunneler.on('open', wsHandlers.onOpen); |     wstunneler.on('open', wsHandlers.onOpen); | ||||||
|     wstunneler.on('close', wsHandlers.onClose); |     wstunneler.on('close', wsHandlers.onClose); | ||||||
| @ -601,7 +607,7 @@ function run(state) { | |||||||
|   }; |   }; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| module.exports.connect = run; | module.exports.connect = _connect; | ||||||
| module.exports.createConnection = run; | module.exports.createConnection = _connect; | ||||||
| 
 | 
 | ||||||
| }()); | }()); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user