diff options
author | 2021-08-13 00:45:01 +0530 | |
---|---|---|
committer | 2021-08-13 00:45:01 +0530 | |
commit | 2d27d5e66649d4f5baf127a53ee5ae524eae3a59 (patch) | |
tree | c592ea219ac8cd987fc367f57b54034c450ab2ab /src/electron/ipc-api/localServer.js | |
parent | Ferdi v5.6.0 (diff) | |
parent | 5.6.1-nightly.24 [skip ci] (diff) | |
download | ferdium-app-2d27d5e66649d4f5baf127a53ee5ae524eae3a59.tar.gz ferdium-app-2d27d5e66649d4f5baf127a53ee5ae524eae3a59.tar.zst ferdium-app-2d27d5e66649d4f5baf127a53ee5ae524eae3a59.zip |
chore: merge from nightly branch into release branch in prep for next beta
Diffstat (limited to 'src/electron/ipc-api/localServer.js')
-rw-r--r-- | src/electron/ipc-api/localServer.js | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/electron/ipc-api/localServer.js b/src/electron/ipc-api/localServer.js index 9b800fdf6..591e70504 100644 --- a/src/electron/ipc-api/localServer.js +++ b/src/electron/ipc-api/localServer.js | |||
@@ -1,9 +1,9 @@ | |||
1 | import { ipcMain, app } from 'electron'; | 1 | import { ipcMain } from 'electron'; |
2 | import net from 'net'; | 2 | import net from 'net'; |
3 | import { LOCAL_HOSTNAME, LOCAL_PORT } from '../../config'; | ||
4 | import { userDataPath } from '../../environment'; | ||
3 | import startServer from '../../internal-server/start'; | 5 | import startServer from '../../internal-server/start'; |
4 | 6 | ||
5 | const DEFAULT_PORT = 45569; | ||
6 | |||
7 | const portInUse = function (port) { | 7 | const portInUse = function (port) { |
8 | return new Promise((resolve) => { | 8 | return new Promise((resolve) => { |
9 | const server = net.createServer((socket) => { | 9 | const server = net.createServer((socket) => { |
@@ -11,7 +11,7 @@ const portInUse = function (port) { | |||
11 | socket.pipe(socket); | 11 | socket.pipe(socket); |
12 | }); | 12 | }); |
13 | 13 | ||
14 | server.listen(port, '127.0.0.1'); | 14 | server.listen(port, LOCAL_HOSTNAME); |
15 | server.on('error', () => { | 15 | server.on('error', () => { |
16 | resolve(true); | 16 | resolve(true); |
17 | }); | 17 | }); |
@@ -28,15 +28,15 @@ export default (params) => { | |||
28 | ipcMain.on('startLocalServer', () => { | 28 | ipcMain.on('startLocalServer', () => { |
29 | if (!localServerStarted) { | 29 | if (!localServerStarted) { |
30 | // Find next unused port for server | 30 | // Find next unused port for server |
31 | let port = DEFAULT_PORT; | 31 | let port = LOCAL_PORT; |
32 | (async () => { | 32 | (async () => { |
33 | // eslint-disable-next-line no-await-in-loop | 33 | // eslint-disable-next-line no-await-in-loop |
34 | while ((await portInUse(port)) && port < DEFAULT_PORT + 10) { | 34 | while ((await portInUse(port)) && port < LOCAL_PORT + 10) { |
35 | port += 1; | 35 | port += 1; |
36 | } | 36 | } |
37 | console.log('Starting local server on port', port); | 37 | console.log('Starting local server on port', port); |
38 | 38 | ||
39 | startServer(app.getPath('userData'), port); | 39 | startServer(userDataPath(), port); |
40 | 40 | ||
41 | params.mainWindow.webContents.send('localServerPort', { | 41 | params.mainWindow.webContents.send('localServerPort', { |
42 | port, | 42 | port, |