diff options
| -rw-r--r-- | app/app.js | 9 | ||||
| -rw-r--r-- | app/lib/backend.js | 7 | ||||
| -rw-r--r-- | app/lib/ipc-facade.js | 6 | ||||
| -rw-r--r-- | app/main.js | 4 | ||||
| -rw-r--r-- | test/mocks/ipc.js | 1 |
5 files changed, 22 insertions, 5 deletions
diff --git a/app/app.js b/app/app.js index c0682343c3..c07f267617 100644 --- a/app/app.js +++ b/app/app.js @@ -34,9 +34,12 @@ ipcRenderer.on('backend-info', (_event, args) => { } }); }); -ipcRenderer.on('disconnect', () => { - log.info('Been told by the node process to disconnect'); - backend.disconnect(); +ipcRenderer.on('shutdown', () => { + log.info('Been told by the node process to shutdown'); + backend.shutdown() + .catch( e => { + log.warn('Unable to shut down the backend', e.message); + }); }); ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// diff --git a/app/lib/backend.js b/app/lib/backend.js index b7f3f3e489..b210e65e85 100644 --- a/app/lib/backend.js +++ b/app/lib/backend.js @@ -299,6 +299,13 @@ export class Backend { }); } + shutdown(): Promise<void> { + return this._ensureAuthenticated() + .then( () => { + return this._ipc.shutdown(); + }); + } + /** * Start reachability monitoring for online/offline detection * This is currently done via HTML5 APIs but will be replaced later diff --git a/app/lib/ipc-facade.js b/app/lib/ipc-facade.js index c2938ae8f1..8939e82823 100644 --- a/app/lib/ipc-facade.js +++ b/app/lib/ipc-facade.js @@ -40,6 +40,7 @@ export interface IpcFacade { setCustomRelay(RelayEndpoint): Promise<void>, connect(): Promise<void>, disconnect(): Promise<void>, + shutdown(): Promise<void>, getIp(): Promise<Ip>, getLocation(): Promise<Location>, getState(): Promise<BackendState>, @@ -109,6 +110,11 @@ export class RealIpc implements IpcFacade { .then(this._ignoreResponse); } + shutdown(): Promise<void> { + return this._ipc.send('shutdown') + .then(this._ignoreResponse); + } + getIp(): Promise<Ip> { return this._ipc.send('get_ip') .then(raw => { diff --git a/app/main.js b/app/main.js index f39e5dc429..cc47a57cb2 100644 --- a/app/main.js +++ b/app/main.js @@ -96,8 +96,8 @@ const appDelegate = { window.loadURL('file://' + path.join(__dirname, 'index.html')); window.on('close', () => { - log.debug('The browser window is closing, disconnecting the tunnel...'); - window.webContents.send('disconnect'); + log.debug('The browser window is closing, shutting down the tunnel...'); + window.webContents.send('shutdown'); }); // create tray icon on macOS diff --git a/test/mocks/ipc.js b/test/mocks/ipc.js index 5b337ebbc9..e3f9cf43a3 100644 --- a/test/mocks/ipc.js +++ b/test/mocks/ipc.js @@ -39,6 +39,7 @@ export function newMockIpc() { disconnect: () => { return new Promise(r => r()); }, + shutdown: Promise.resolve, getIp: () => { return new Promise(r => r('1.2.3.4')); }, |
