added protection against unwanted writes to websocket
This commit is contained in:
		
							parent
							
								
									aff82cebe9
								
							
						
					
					
						commit
						701aa99a30
					
				| @ -96,6 +96,7 @@ module.exports.create = function (copts) { | |||||||
|         return; |         return; | ||||||
|       } |       } | ||||||
| 
 | 
 | ||||||
|  |       remote.closing[cid] = true; | ||||||
|       PromiseA.resolve() |       PromiseA.resolve() | ||||||
|         .then(function () { |         .then(function () { | ||||||
|           remote.clients[cid].end(); |           remote.clients[cid].end(); | ||||||
| @ -117,6 +118,9 @@ module.exports.create = function (copts) { | |||||||
|         .catch(function (err) { |         .catch(function (err) { | ||||||
|           console.warn('failed to close browser connection', cid, err); |           console.warn('failed to close browser connection', cid, err); | ||||||
|         }) |         }) | ||||||
|  |         .then(function () { | ||||||
|  |           delete remote.closing[cid]; | ||||||
|  |         }) | ||||||
|         ; |         ; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -155,6 +159,7 @@ module.exports.create = function (copts) { | |||||||
|       token.deviceId = (token.device && (token.device.id || token.device.hostname)) || token.domains.join(','); |       token.deviceId = (token.device && (token.device.id || token.device.hostname)) || token.domains.join(','); | ||||||
|       token.ws = ws; |       token.ws = ws; | ||||||
|       token.clients = {}; |       token.clients = {}; | ||||||
|  |       token.closing = {}; | ||||||
| 
 | 
 | ||||||
|       token.domains.forEach(function (domainname) { |       token.domains.forEach(function (domainname) { | ||||||
|         console.log('domainname', domainname); |         console.log('domainname', domainname); | ||||||
| @ -366,7 +371,7 @@ module.exports.create = function (copts) { | |||||||
|     console.log('[pipeWs] browser is', cid, 'home-cloud is', packer.socketToId(remote.ws.upgradeReq.socket)); |     console.log('[pipeWs] browser is', cid, 'home-cloud is', packer.socketToId(remote.ws.upgradeReq.socket)); | ||||||
| 
 | 
 | ||||||
|     function sendWs(data, serviceOverride) { |     function sendWs(data, serviceOverride) { | ||||||
|       if (remote.ws) { |       if (remote.ws && !remote.closing[cid]) { | ||||||
|         try { |         try { | ||||||
|           remote.ws.send(packer.pack(browserAddr, data, serviceOverride), { binary: true }); |           remote.ws.send(packer.pack(browserAddr, data, serviceOverride), { binary: true }); | ||||||
|         } catch (err) { |         } catch (err) { | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user