forked from coolaj86/telebit.js
		
	check for auth error
This commit is contained in:
		
							parent
							
								
									fdf5b46a9c
								
							
						
					
					
						commit
						2333ec30f6
					
				
							
								
								
									
										12
									
								
								wsclient.js
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								wsclient.js
									
									
									
									
									
								
							| @ -136,13 +136,9 @@ function run(copts) { | |||||||
|       return Object.keys(localclients).length; |       return Object.keys(localclients).length; | ||||||
|     } |     } | ||||||
|   }; |   }; | ||||||
| 
 |  | ||||||
|   var wsHandlers = { |   var wsHandlers = { | ||||||
|     onOpen: function () { |     onOpen: function () { | ||||||
|       console.info("[open] connected to '" + copts.stunneld + "'"); |       console.info("[open] connected to '" + copts.stunneld + "'"); | ||||||
| 
 |  | ||||||
|       var machine = require('tunnel-packer').create(handlers); |  | ||||||
|       wstunneler.on('message', machine.fns.addChunk); |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|   , onClose: function () { |   , onClose: function () { | ||||||
| @ -185,11 +181,19 @@ function run(copts) { | |||||||
|       } |       } | ||||||
|     } |     } | ||||||
|   }; |   }; | ||||||
|  |   var machine = require('tunnel-packer').create(handlers); | ||||||
| 
 | 
 | ||||||
|   console.info("[connect] '" + copts.stunneld + "'"); |   console.info("[connect] '" + copts.stunneld + "'"); | ||||||
| 
 | 
 | ||||||
|   wstunneler = new WebSocket(tunnelUrl, { rejectUnauthorized: !copts.insecure }); |   wstunneler = new WebSocket(tunnelUrl, { rejectUnauthorized: !copts.insecure }); | ||||||
|   wstunneler.on('open', wsHandlers.onOpen); |   wstunneler.on('open', wsHandlers.onOpen); | ||||||
|  |   wstunneler.on('message', function (data, flags) { | ||||||
|  |     if (data.error || '{' === data[0]) { | ||||||
|  |       console.log(data); | ||||||
|  |       return; | ||||||
|  |     } | ||||||
|  |     machine.fns.addChunk(data, flags); | ||||||
|  |   }); | ||||||
|   wstunneler.on('close', wsHandlers.onClose); |   wstunneler.on('close', wsHandlers.onClose); | ||||||
|   wstunneler.on('error', wsHandlers.onError); |   wstunneler.on('error', wsHandlers.onError); | ||||||
|   process.on('exit', wsHandlers.onExit); |   process.on('exit', wsHandlers.onExit); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user