Skip to content
This repository was archived by the owner on May 31, 2022. It is now read-only.

Commit 15bb356

Browse files
feat: provide driver url with ssh injected (#279)
1 parent 6c35413 commit 15bb356

File tree

7 files changed

+182
-199
lines changed

7 files changed

+182
-199
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,8 +387,9 @@ const derivedProps = c.getAttributes({ derived: true });
387387
| ----- | ---- | ---------- | ---- |
388388
| `instanceId` | String | The mongoscope | `localhost:27017` |
389389
| `driverAuthMechanism` | String | Converts the value of `authStrategy` for humans into the `authMechanism` value for the driver | `undefined` |
390-
| `driverUrl` | String | The first argument `mongoscope-server` passes to `mongodb.connect` | `mongodb://localhost:27017/?readPreference=primary&ssl=false` |
391-
| `safeUrl` | String | The url where a password is replaced with stars | `mongodb://localhost:27017/?readPreference=primary&ssl=false` |
390+
| `safeUrl` | String | The URL where a password is replaced with stars | `mongodb://localhost:27017/?readPreference=primary&ssl=false` |
391+
| `driverUrl` | String | Use this URL in order to connect via DataService | `mongodb://localhost:27017/?readPreference=primary&ssl=false` |
392+
| `driverUrlWithSsh` | String | Use this URL in order to connect via connection model itself | `mongodb://localhost:29201/?readPreference=primary&ssl=false` |
392393
| `driverOptions` | String | The second argument `mongoscope-server` passes to `mongodb.connect` | `{}` |
393394

394395
## Events

lib/connect.js

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ const async = require('async');
44
const {
55
includes,
66
clone,
7-
cloneDeep,
87
assign,
98
isString,
109
isFunction,
@@ -211,17 +210,7 @@ const getTasks = (model, setupListeners) => {
211210
validOptions.useNewUrlParser = true;
212211
validOptions.useUnifiedTopology = true;
213212

214-
const modelClone = cloneDeep(model, true);
215-
216-
if (model.sshTunnel !== 'NONE') {
217-
// Populate the SSH Tunnel options correctly
218-
modelClone.set({
219-
hostname: model.sshTunnelOptions.localAddr,
220-
port: model.sshTunnelOptions.localPort
221-
});
222-
}
223-
224-
const mongoClient = new MongoClient(modelClone.driverUrl, validOptions);
213+
const mongoClient = new MongoClient(model.driverUrlWithSsh, validOptions);
225214

226215
if (setupListeners) {
227216
setupListeners(mongoClient);

lib/connection-collection.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,9 @@ let basepath;
1313

1414
try {
1515
const electron = require('electron');
16+
1617
appName = electron.remote ? electron.remote.app.getName() : undefined;
17-
basepath = electron.remote
18-
? electron.remote.app.getPath('userData')
19-
: undefined;
18+
basepath = electron.remote ? electron.remote.app.getPath('userData') : undefined;
2019
} catch (e) {
2120
/* eslint no-console: 0 */
2221
console.log('Could not load electron', e.message);

lib/extended-model.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const Connection = require('./model');
22
const storageMixin = require('storage-mixin');
3-
const uuid = require('uuid');
3+
const { v4: uuidv4 } = require('uuid');
44

55
/**
66
* The name of a remote electon application that
@@ -33,10 +33,8 @@ const ExtendedConnection = Connection.extend(storageMixin, {
3333
secureCondition: (val, key) => key.match(/(password|passphrase)/i)
3434
},
3535
props: {
36-
_id: { type: 'string', default: () => uuid.v4() },
37-
/**
38-
* Updated on each successful connection to the Deployment.
39-
*/
36+
_id: { type: 'string', default: () => uuidv4() },
37+
// Updated on each successful connection to the Deployment.
4038
lastUsed: { type: 'date', default: null },
4139
isFavorite: { type: 'boolean', default: false },
4240
name: { type: 'string', default: 'Local' },

0 commit comments

Comments
 (0)