From d2d5e6bc24ec51f56c62d09366388a1568f49771 Mon Sep 17 00:00:00 2001 From: junkern Date: Sun, 5 Apr 2020 11:07:01 +0200 Subject: [PATCH] src: Implement custom server port. --- src/Connection.ts | 1 + test/docker-compose.yml | 8 ++++++++ test/test.ts | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Connection.ts b/src/Connection.ts index 31fe435..1c1d8c2 100644 --- a/src/Connection.ts +++ b/src/Connection.ts @@ -141,6 +141,7 @@ class SSHConnection { return new Promise(async (resolve) => { const options = { host, + port: this.options.endPort, username: this.options.username, privateKey: this.options.privateKey } diff --git a/test/docker-compose.yml b/test/docker-compose.yml index eac5332..0d7afa2 100644 --- a/test/docker-compose.yml +++ b/test/docker-compose.yml @@ -7,6 +7,14 @@ services: context: ./ dockerfile: ./server/Dockerfile + server-different-port: + ports: + - 23:23 + build: + context: ./ + dockerfile: ./server/Dockerfile + command: /usr/sbin/sshd -D -p 23 + bastion: ports: - 22:22 diff --git a/test/test.ts b/test/test.ts index 5c39d89..d7617af 100644 --- a/test/test.ts +++ b/test/test.ts @@ -46,7 +46,7 @@ describe('node-ssh-forward', async () => { it('with a custom end port', async () => { const ssh = new SSHConnection({ username: 'root', - endHost: 'server', + endHost: 'server-different-port', endPort: 23 }) await ssh.executeCommand('uptime')