diff --git a/package.json b/package.json index 95bb0b7..0319e3e 100644 --- a/package.json +++ b/package.json @@ -32,14 +32,14 @@ }, "homepage": "https://github.com/Teletunnel/teletunnel-protocols#readme", "devDependencies": { - "aegir": "^15.1.0" + "aegir": "^15.1.0", + "teletunnel-core": "github:Teletunnel/teletunnel-core" }, "dependencies": { "mafmt": "^6.0.0", "pull-stream-to-net-socket": "^1.0.0", "sni": "^1.0.0", - "stream-to-pull-stream": "^1.7.2", - "teletunnel-core": "github:Teletunnel/teletunnel-core" + "stream-to-pull-stream": "^1.7.2" }, "contributors": [ "Maciej Krüger " diff --git a/src/tcp-protos/ssh.js b/src/tcp-protos/ssh.js index 67a736e..f920901 100644 --- a/src/tcp-protos/ssh.js +++ b/src/tcp-protos/ssh.js @@ -9,15 +9,17 @@ module.exports = { } }, detect: async (conn) => { // ssh client sends SSH-2.0\r\n - let version = String(await conn.read(7)) - - if (version !== 'SSH-2.0') { + if (String(await conn.read(8)) !== 'SSH-2.0-') { return false } + let version = '' let next - while ((next = String(await conn.read(1))) !== '\r') { // TODO: add reading limit - version += next + while (version.length < 100) { + while ((next = String(await conn.read(1))) !== '\r') { + version += next + } + break } return {version} diff --git a/test/ssh.spec.js b/test/ssh.spec.js index c6494d5..e382749 100644 --- a/test/ssh.spec.js +++ b/test/ssh.spec.js @@ -9,6 +9,6 @@ const assert = require('assert') describe('ssh', () => { it('ssh module detects ssh', async () => { - assert.deepStrictEqual(await ssh.detect(conn()), {version: 'SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.4'}) + assert.deepStrictEqual(await ssh.detect(conn()), {version: 'OpenSSH_7.2p2 Ubuntu-4ubuntu2.4'}) }) })