mirror of
https://github.com/NuSkooler/enigma-bbs.git
synced 2025-07-22 18:56:00 +02:00
+ Concept of PluginModule and inherited classes such as ServerModule, MenuModule, ...
* Client now tracks current menu module. Auto detach events, etc.
This commit is contained in:
parent
d3e35d286a
commit
f7462bbbdd
11 changed files with 226 additions and 60 deletions
|
@ -25,7 +25,7 @@ function SSHClient(input, output) {
|
|||
this.input.on('authentication', function onAuthentication(ctx) {
|
||||
console.log('auth: ' + ctx.method);
|
||||
|
||||
if('password' == ctx.method) {
|
||||
if('password' === ctx.method) {
|
||||
// :TODO: Log attempts
|
||||
user.authenticate(ctx.username, ctx.password, self, function onAuthResult(isAuth) {
|
||||
if(isAuth) {
|
||||
|
@ -34,9 +34,19 @@ function SSHClient(input, output) {
|
|||
ctx.reject();
|
||||
}
|
||||
});
|
||||
} else if('publickey' == ctx.method) {
|
||||
} else if('publickey' === ctx.method) {
|
||||
console.log('pub key path');
|
||||
} else if('keyboard-interactive' === ctx.method) {
|
||||
ctx.reject(['password']);
|
||||
// :TODO: support this. Allow users to generate a key for use or w/e
|
||||
|
||||
/*} else if('keyboard-interactive' === ctx.method) {
|
||||
console.log(ctx.submethods); // :TODO: proper logging; handle known types, etc.
|
||||
|
||||
ctx.prompt([ { prompt : 'Password: ', echo : false } ], function onPromptResponses(err, responses) {
|
||||
console.log(err);
|
||||
console.log(responses);
|
||||
});*/
|
||||
} else {
|
||||
ctx.reject();
|
||||
}
|
||||
|
@ -44,10 +54,10 @@ function SSHClient(input, output) {
|
|||
|
||||
this.input.on('ready', function onReady() {
|
||||
console.log('Client authenticated');
|
||||
});
|
||||
|
||||
this.input.on('session', function onSession(accept, reject) {
|
||||
var session = accept();
|
||||
self.input.on('session', function onSession(accept, reject) {
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
this.input.on('end', function onEnd() {
|
||||
|
@ -66,7 +76,8 @@ function createServer() {
|
|||
};
|
||||
|
||||
var server = ssh2.Server(serverConf);
|
||||
server.on('connection', function onConnection(conn) {
|
||||
server.on('connection', function onConnection(conn, info) {
|
||||
console.log(info); // :TODO: Proper logging
|
||||
var client = new SSHClient(conn, conn);
|
||||
this.emit('client', client);
|
||||
});
|
||||
|
|
|
@ -2,14 +2,16 @@
|
|||
'use strict';
|
||||
|
||||
// ENiGMA½
|
||||
var baseClient = require('../client.js');
|
||||
var logger = require('../logger.js');
|
||||
var baseClient = require('../client.js');
|
||||
var logger = require('../logger.js');
|
||||
var ServerModule = require('../server_module.js').ServerModule;
|
||||
|
||||
var net = require('net');
|
||||
var buffers = require('buffers');
|
||||
var binary = require('binary');
|
||||
var stream = require('stream');
|
||||
var assert = require('assert');
|
||||
var net = require('net');
|
||||
var buffers = require('buffers');
|
||||
var binary = require('binary');
|
||||
var stream = require('stream');
|
||||
var assert = require('assert');
|
||||
var util = require('util');
|
||||
|
||||
//var debug = require('debug')('telnet');
|
||||
|
||||
|
@ -19,7 +21,8 @@ exports.moduleInfo = {
|
|||
author : 'NuSkooler'
|
||||
};
|
||||
|
||||
exports.createServer = createServer;
|
||||
exports.getModule = TelnetServerModule;
|
||||
|
||||
|
||||
//
|
||||
// Telnet Protocol Resources
|
||||
|
@ -469,7 +472,7 @@ function TelnetClient(input, output) {
|
|||
});
|
||||
}
|
||||
|
||||
require('util').inherits(TelnetClient, baseClient.Client);
|
||||
util.inherits(TelnetClient, baseClient.Client);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Telnet Command/Option handling
|
||||
|
@ -716,7 +719,7 @@ Object.keys(OPTIONS).forEach(function(name) {
|
|||
});
|
||||
});
|
||||
|
||||
|
||||
/*
|
||||
function createServer() {
|
||||
var server = net.createServer(function onConnection(sock) {
|
||||
var self = this;
|
||||
|
@ -729,3 +732,27 @@ function createServer() {
|
|||
|
||||
return server;
|
||||
}
|
||||
*/
|
||||
|
||||
function TelnetServerModule() {
|
||||
console.log('TelnetServerModule')
|
||||
ServerModule.call(this);
|
||||
}
|
||||
|
||||
util.inherits(TelnetServerModule, ServerModule);
|
||||
|
||||
TelnetServerModule.prototype.createServer = function() {
|
||||
console.log('TelnetServerModule createServer')
|
||||
TelnetServerModule.super_.prototype.createServer.call(this);
|
||||
|
||||
var server = net.createServer(function onConnection(sock) {
|
||||
var self = this;
|
||||
var client = new TelnetClient(sock, sock);
|
||||
|
||||
client.banner();
|
||||
|
||||
self.emit('client', client);
|
||||
});
|
||||
|
||||
return server;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue