Skip to content
This repository has been archived by the owner on Mar 15, 2021. It is now read-only.

Commit

Permalink
Fix SSH tunnel local port
Browse files Browse the repository at this point in the history
The ssh tunnel was using a port variable that was not defined yet.
I don't know how this was working with electron 0.x versions.
But with electron 1.x that was not working. Probably some upgrade in the v8 has made this wrong behaviour does not work anymore.
Well, this code fix that.
  • Loading branch information
maxcnunes committed Jun 1, 2016
1 parent 7052fee commit 66829b4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/db/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ async function connect(server, database) {
debug('creating ssh tunnel');
server.sshTunnel = await connectTunnel(server.config);

const localPort = server.sshTunnel.address().port;
debug('ssh forwarding through local port connection %d', localPort);
const { address, port } = server.sshTunnel.address();
debug('ssh forwarding through local connection %s:%d', address, port);

server.config.localHost = '127.0.0.1';
server.config.localPort = localPort;
server.config.localHost = address;
server.config.localPort = port;
}

const driver = clients[server.config.client];
Expand Down
1 change: 1 addition & 0 deletions src/db/tunnel.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ async function _configTunnel(serverInfo) {
srcPort: 0,
srcHost: 'localhost',
localHost: 'localhost',
localPort: await getPort(),
};
if (serverInfo.ssh.password) config.password = serverInfo.ssh.password;
if (serverInfo.ssh.passphrase) config.passphrase = serverInfo.ssh.passphrase;
Expand Down

0 comments on commit 66829b4

Please sign in to comment.