mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-30 19:19:03 +01:00 
			
		
		
		
	scan only one port instead of 10, https://github.com/zadam/trilium/issues/1503
This commit is contained in:
		
							parent
							
								
									2d814af7f1
								
							
						
					
					
						commit
						1c75ea89ad
					
				| @ -13,7 +13,7 @@ | |||||||
| 
 | 
 | ||||||
| <h2>Trilium desktop instance</h2> | <h2>Trilium desktop instance</h2> | ||||||
| 
 | 
 | ||||||
| <p>Web clipper by default tries to find a running desktop instance on ports 37740 - 37749. If you configured your Trilium desktop app to run on a different port, you can specify it here (otherwise keep it empty).</p> | <p>Web clipper by default tries to find a running desktop instance on port 37740. If you configured your Trilium desktop app to run on a different port, you can specify it here (otherwise keep it empty).</p> | ||||||
| 
 | 
 | ||||||
| <form id="trilium-desktop-setup-form"> | <form id="trilium-desktop-setup-form"> | ||||||
|     <p> |     <p> | ||||||
|  | |||||||
| @ -53,13 +53,12 @@ class TriliumServerFacade { | |||||||
| 	async triggerSearchForTrilium() { | 	async triggerSearchForTrilium() { | ||||||
| 		this.setTriliumSearch({ status: 'searching' }); | 		this.setTriliumSearch({ status: 'searching' }); | ||||||
| 
 | 
 | ||||||
| 		const startingPort = await this.getStartingPort(); |  | ||||||
| 
 |  | ||||||
| 		for (let testedPort = startingPort; testedPort < startingPort + 10; testedPort++) { |  | ||||||
| 		try { | 		try { | ||||||
| 				console.debug('Trying port ' + testedPort); | 			const port = await this.getPort(); | ||||||
| 
 | 
 | ||||||
| 				const resp = await fetch(`http://127.0.0.1:${testedPort}/api/clipper/handshake`); | 			console.debug('Trying port ' + port); | ||||||
|  | 
 | ||||||
|  | 			const resp = await fetch(`http://127.0.0.1:${port}/api/clipper/handshake`); | ||||||
| 
 | 
 | ||||||
| 			const text = await resp.text(); | 			const text = await resp.text(); | ||||||
| 
 | 
 | ||||||
| @ -70,8 +69,8 @@ class TriliumServerFacade { | |||||||
| 			if (json.appName === 'trilium') { | 			if (json.appName === 'trilium') { | ||||||
| 				this.setTriliumSearchWithVersionCheck(json, { | 				this.setTriliumSearchWithVersionCheck(json, { | ||||||
| 					status: 'found-desktop', | 					status: 'found-desktop', | ||||||
| 						port: testedPort, | 					port: port, | ||||||
| 						url: 'http://127.0.0.1:' + testedPort | 					url: 'http://127.0.0.1:' + port | ||||||
| 				}); | 				}); | ||||||
| 
 | 
 | ||||||
| 				return; | 				return; | ||||||
| @ -80,7 +79,6 @@ class TriliumServerFacade { | |||||||
| 		catch (error) { | 		catch (error) { | ||||||
| 			// continue
 | 			// continue
 | ||||||
| 		} | 		} | ||||||
| 		} |  | ||||||
| 
 | 
 | ||||||
| 		const {triliumServerUrl} = await browser.storage.sync.get("triliumServerUrl"); | 		const {triliumServerUrl} = await browser.storage.sync.get("triliumServerUrl"); | ||||||
| 		const {authToken} = await browser.storage.sync.get("authToken"); | 		const {authToken} = await browser.storage.sync.get("authToken"); | ||||||
| @ -136,7 +134,7 @@ class TriliumServerFacade { | |||||||
| 		}); | 		}); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	async getStartingPort() { | 	async getPort() { | ||||||
| 		const {triliumDesktopPort} = await browser.storage.sync.get("triliumDesktopPort"); | 		const {triliumDesktopPort} = await browser.storage.sync.get("triliumDesktopPort"); | ||||||
| 
 | 
 | ||||||
| 		if (triliumDesktopPort) { | 		if (triliumDesktopPort) { | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 zadam
						zadam