* More WIP on door support. Proof of concept mostly functional-ish for at least Pimpwars :)
This commit is contained in:
126
core/door.js
126
core/door.js
@@ -1,89 +1,73 @@
|
||||
/* jslint node: true */
|
||||
'use strict';
|
||||
|
||||
var Config = require('./config.js').config;
|
||||
var spawn = require('child_process').spawn;
|
||||
var events = require('events');
|
||||
|
||||
var _ = require('lodash');
|
||||
var pty = require('pty');
|
||||
|
||||
exports.DropFile = DropFile;
|
||||
exports.Door = Door;
|
||||
|
||||
//
|
||||
// Resources
|
||||
// * http://goldfndr.home.mindspring.com/dropfile/
|
||||
// * https://en.wikipedia.org/wiki/Talk%3ADropfile
|
||||
// * http://thoughtproject.com/libraries/bbs/Sysop/Doors/DropFiles/index.htm
|
||||
function Door(client, exeInfo) {
|
||||
events.EventEmitter.call(this);
|
||||
|
||||
// http://lord.lordlegacy.com/dosemu/
|
||||
this.client = client;
|
||||
this.exeInfo = exeInfo;
|
||||
|
||||
function DropFile(options) {
|
||||
// exeInfo.cmd
|
||||
// exeInfo.args[]
|
||||
// exeInfo.env{}
|
||||
// exeInfo.cwd
|
||||
// exeInfo.encoding
|
||||
|
||||
var self = this;
|
||||
this.client = options.client;
|
||||
};
|
||||
|
||||
this.fileType = options.fileType || 'DORINFO';
|
||||
this.exe = options.exe || 'dosemu';
|
||||
this.exeParams = options.exeParams || [];
|
||||
require('util').inherits(Door, events.EventEmitter);
|
||||
|
||||
|
||||
Object.defineProperty(this, 'fileName', {
|
||||
get : function() {
|
||||
return {
|
||||
DOOR : 'DOOR.SYS', // GAP BBS, many others
|
||||
DOOR32 : 'DOOR32.SYS', // EleBBS / Mystic, Syncronet, Maximus, Telegard, AdeptXBBS, ...
|
||||
CALLINFO : 'CALLINFO.BBS', // Citadel?
|
||||
DORINFO : self.getDoorInfoXFileName(), // RBBS, RemoteAccess, QBBS, ...
|
||||
CHAIN : 'CHAIN.TXT', // WWIV
|
||||
CURRUSER : 'CURRUSER.BBS', // RyBBS
|
||||
SFDOORS : 'SFDOORS.DAT', // Spitfire
|
||||
PCBOARD : 'PCBOARD.SYS', // PCBoard
|
||||
TRIBBS : 'TRIBBS.SYS', // TriBBS
|
||||
USERINFO : 'USERINFO.DAT', // Wildcat! 3.0+
|
||||
JUMPER : 'JUMPER.DAT', // 2AM BBS
|
||||
SXDOOR : // System/X, dESiRE
|
||||
'SXDOOR.' + _.pad(self.client.node.toString(), 3, '0'),
|
||||
INFO : 'INFO.BBS', // Phoenix BBS
|
||||
}[self.fileType.toUpperCase()];
|
||||
}
|
||||
|
||||
Door.prototype.run = function() {
|
||||
|
||||
var self = this;
|
||||
|
||||
var doorProc = spawn(this.exeInfo.cmd, this.exeInfo.args);
|
||||
|
||||
/*
|
||||
doorProc.stderr.pipe(self.client.term.output);
|
||||
doorProc.stdout.pipe(self.client.term.output);
|
||||
doorProc.stdout.on('data', function stdOutData(data) {
|
||||
console.log('got data')
|
||||
self.client.term.write(data);
|
||||
});
|
||||
|
||||
this.getDoorInfoXFileName = function() {
|
||||
var x;
|
||||
var node = self.client.node;
|
||||
if(10 === node) {
|
||||
x = 0;
|
||||
} else if(node < 10) {
|
||||
x = node;
|
||||
} else {
|
||||
x = String.fromCharCode('a'.charCodeAt(0) + (node - 11));
|
||||
}
|
||||
return 'DORINFO' + x + '.DEF';
|
||||
};
|
||||
doorProc.stderr.on('data', function stdErrData(data) {
|
||||
console.log('got error data')
|
||||
self.client.term.write(data);
|
||||
});
|
||||
|
||||
this.getDoorInfoXContents = function() {
|
||||
// :TODO: fix sysop first name, last name (load @ system load if avail)
|
||||
// :TODO: fix time remaining
|
||||
doorProc.on('close', function closed(exitCode) {
|
||||
console.log('closed')
|
||||
self.emit('closed', exitCode); // just fwd on
|
||||
});
|
||||
*/
|
||||
var door = pty.spawn(this.exeInfo.cmd, this.exeInfo.args, {
|
||||
cols : self.client.term.termWidth,
|
||||
rows : self.client.term.termHeight,
|
||||
});
|
||||
|
||||
//
|
||||
// Resources:
|
||||
// * http://goldfndr.home.mindspring.com/dropfile/dorinfo.htm
|
||||
//
|
||||
return [
|
||||
Config.general.boardName, // "The name of the system."
|
||||
'SysOp First', // "The sysop's name up to the first space."
|
||||
'SysOp Last', // "The sysop's name following the first space."
|
||||
'COM1', // "The serial port the modem is connected to, or 0 if logged in on console."
|
||||
'57600', // "The current port (DTE) rate."
|
||||
'0', // "The number "0""
|
||||
/[^\s]*/.exec(self.client.user.username)[0], // "The current user's name, up to the first space."
|
||||
/[^\s]*/.exec(self.client.user.username)[0], // "The current user's name, following the first space."
|
||||
self.client.user.properties.location || '', // "Where the user lives, or a blank line if unknown."
|
||||
'1', // "The number "0" if TTY, or "1" if ANSI."
|
||||
self.client.user.isSysOp() ? '100' : '30', // "The number 5 for problem users, 30 for regular users, 80 for Aides, and 100 for Sysops."
|
||||
'546', // "The number of minutes left in the current user's account, limited to 546 to keep from overflowing other software."
|
||||
'-1' // "The number "-1" if using an external serial driver or "0" if using internal serial routines."
|
||||
].join('\r\n') + '\r\n';
|
||||
};
|
||||
//door.pipe(self.client.term.output);
|
||||
self.client.term.output.pipe(door);
|
||||
|
||||
}
|
||||
// :TODO: do this with pluggable pipe/filter classes
|
||||
|
||||
DropFile.fileTypes = [ 'DORINFO' ];
|
||||
door.setEncoding('cp437');
|
||||
door.on('data', function doorData(data) {
|
||||
self.client.term.write(data);
|
||||
//console.log(data);
|
||||
});
|
||||
//*/
|
||||
|
||||
door.on('close', function closed() {
|
||||
console.log('closed...')
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user