From 3833f9910e8b4f2ef2cee7d04fcf3aee0544acf7 Mon Sep 17 00:00:00 2001 From: Bryan Ashby Date: Mon, 19 Oct 2015 22:33:11 -0600 Subject: [PATCH] * Update some packages * Still trying to figure out ssh2 --- core/connect.js | 3 --- core/servers/ssh.js | 47 +++++++++++++++++++++++++++++++------ package.json | 56 ++++++++++++++++++++++----------------------- 3 files changed, 68 insertions(+), 38 deletions(-) diff --git a/core/connect.js b/core/connect.js index 2946be90..47afeb33 100644 --- a/core/connect.js +++ b/core/connect.js @@ -6,9 +6,6 @@ var theme = require('./theme.js'); var moduleUtil = require('./module_util.js'); var Config = require('./config.js').config; - -var packageJson = require('../package.json'); - var assert = require('assert'); var util = require('util'); diff --git a/core/servers/ssh.js b/core/servers/ssh.js index f457769e..9a88aa84 100644 --- a/core/servers/ssh.js +++ b/core/servers/ssh.js @@ -8,6 +8,11 @@ var Log = require('../logger.js').log; var ServerModule = require('../server_module.js').ServerModule; var userLogin = require('../user_login.js').userLogin; +// :TODO: remove this - currently an experimental hack: +var term = require('../client_term.js'); + +var packageJson = require('../../package.json'); + var ssh2 = require('ssh2'); var fs = require('fs'); var util = require('util'); @@ -32,7 +37,12 @@ function SSHClient(clientConn) { var self = this; clientConn.on('authentication', function authentication(ctx) { - self.log.trace( { context : ctx }, 'SSH authentication'); + self.log.trace( + { + domain : ctx.domain, + username : ctx.username, + method : ctx.method, + }, 'SSH authentication'); // :TODO: check Config max failed logon attempts/etc. @@ -84,7 +94,7 @@ function SSHClient(clientConn) { break; default : - self.log.info( { method : ctx.method }, 'Unsupported SSH authentication method. Rejecting connection.'); + self.log.info( { method : ctx.method }, 'Unsupported SSH authentication method'); ctx.reject(); } }); @@ -93,13 +103,35 @@ function SSHClient(clientConn) { self.log.info('SSH authentication success'); clientConn.on('session', function sess(accept, reject) { - self.input = accept(); - self.output = self.input; + + var session = accept(); + + session.on('pty-req', function pty(accept, reject, info) { + console.log(info); + var channel = accept(); + console.log(channel) + + }); + + session.on('shell', function shell(accept, reject) { + var channel = accept(); + + channel._write('Hello, world!') + + self.input = channel._client._sock; + self.output = channel._client._sock; + + + self.term = new term.ClientTerminal(self.output); + + self.emit('ready') + }); + }); }); clientConn.on('end', function clientEnd() { - self.emit('end'); + //self.emit('end'); }); } @@ -117,12 +149,13 @@ SSHServerModule.prototype.createServer = function() { // :TODO: setup all options here. What should the banner, etc. really be???? var serverConf = { privateKey : fs.readFileSync(conf.config.servers.ssh.rsaPrivateKey), - banner : 'ENiGMA½ BBS SSH Server', + banner : 'ENiGMA½ BBS ' + packageJson.version + ' SSH Server', + ident : 'enigma-bbs-' + packageJson.version + '-srv', debug : function debugSsh(dbgLine) { if(true === conf.config.servers.ssh.debugConnections) { self.log.trace('SSH: ' + dbgLine); } - } + }, }; var server = ssh2.Server(serverConf); diff --git a/package.json b/package.json index 3c86680a..5fc56d2f 100644 --- a/package.json +++ b/package.json @@ -1,29 +1,29 @@ { - "name" : "enigma-bbs", - "version" : "0.0.1-alpha", - "description" : "ENiGMA½ Bulletin Board System", - "author" : "Bryan Ashby ", - "license" : "BSD-2-Clause", - "keywords" : [ - "bbs", - "telnet" - ], - "dependencies" : { - "async" : "1.4.x", - "binary" : "0.3.x", - "buffers" : "0.1.x", - "bunyan" : "1.5.x", - "iconv-lite" : "0.4.x", - "lodash" : "3.10.x", - "sqlite3" : "3.1.x", - "ssh2" : "0.4.x", - "node-uuid" : "1.4.x", - "moment" : "2.10.x", - "gaze" : "0.5.x", - "mkdirp" : "0.5.x", - "pty.js" : "0.3.x", - "string-format" : "davidchambers/string-format#mini-language", - "hjson" : "1.7.x" - }, - "engine" : "node >= 0.12.2" -} \ No newline at end of file + "name": "enigma-bbs", + "version": "0.0.1-alpha", + "description": "ENiGMA½ Bulletin Board System", + "author": "Bryan Ashby ", + "license": "BSD-2-Clause", + "keywords": [ + "bbs", + "telnet" + ], + "dependencies": { + "async": "1.4.x", + "binary": "0.3.x", + "buffers": "0.1.x", + "bunyan": "1.5.x", + "gaze": "^0.5.2", + "hjson": "1.7.x", + "iconv-lite": "^0.4.13", + "lodash": "^3.10.1", + "mkdirp": "0.5.x", + "moment": "^2.10.6", + "node-uuid": "1.4.x", + "pty.js": "0.3.x", + "sqlite3": "3.1.x", + "ssh2": "^0.4.11", + "string-format": "davidchambers/string-format#mini-language" + }, + "engine": "node >= 0.12.2" +}