Compare commits

..

34 Commits

Author SHA1 Message Date
Bryan Ashby 6aa0c8679f
Merge pull request #520 from NuSkooler/feature/multiarch_docker
Feature/multiarch docker
2023-10-15 17:34:09 -06:00
Nathan Byrd 6b169de3ac Added missing change directory 2023-10-15 20:43:31 +00:00
Nathan Byrd 362f443290 Changed copy to directory location 2023-10-15 20:37:35 +00:00
Nathan Byrd 8a97f79d8c Removed old python package 2023-10-15 20:22:16 +00:00
Nathan Byrd f17bbe7c5a Updated docker support 2023-10-15 20:17:47 +00:00
Bryan Ashby 8c7df1fe75 Oops! 2023-10-12 20:41:59 -06:00
Bryan Ashby b00d5d07dd
Merge pull request #510 from NuSkooler/bugfix/scrolling_updates
Bugfix/scrolling updates
2023-10-12 20:36:54 -06:00
Bryan Ashby bbfef536e0
Merge pull request #489 from NuSkooler/bugfix/node_v20
Updated node-pty to support new node versions
2023-10-12 20:28:00 -06:00
Bryan Ashby 83636cb894 Sync up with master 2023-10-12 20:25:01 -06:00
Bryan Ashby ca985dd2cb Fix onExit(): emits a object containing exitCode and signal 2023-10-12 20:21:49 -06:00
Bryan Ashby b87ff51160 Merge branch 'bugfix/node_v20' of github.com:NuSkooler/enigma-bbs into bugfix/node_v20 2023-10-12 20:06:10 -06:00
Bryan Ashby 746233fa56 Updated lock 2023-10-12 20:05:45 -06:00
Bryan Ashby c84b3ee1c1
Merge pull request #515 from NuSkooler/bugfix/ssh_doc_updates
Updated the SSH version, config, and documentation
2023-10-11 19:43:21 -06:00
Bryan Ashby 1a99153431
Merge pull request #514 from NuSkooler/bugfix/dev_env_python
Small bugfix on dev container startup to lock python version
2023-10-10 16:52:42 -06:00
Nathan Byrd 88a1b0ea69 locked python version to fix startup issue 2023-10-10 20:42:15 +00:00
Nathan Byrd 498c4a6082 Additional API changes 2023-10-10 19:43:58 +00:00
Nathan Byrd 577992bbe5 Changes to API for node-pty 2023-10-10 19:33:25 +00:00
Nathan Byrd 402c5d0156 Merge branch 'master' into bugfix/scrolling_updates 2023-09-27 20:56:04 +00:00
Nathan Byrd 0ca22de6e9 Added back in unused escape codes for backwards compat 2023-09-26 22:02:49 +00:00
Nathan Byrd 394ac465c8 Merge remote-tracking branch 'origin/master' into bugfix/scrolling_updates 2023-09-26 21:50:04 +00:00
Nathan Byrd 450ba65565 Fixed missing ansi codes causing formatting misses 2023-09-24 20:39:57 +00:00
Nathan Byrd 72a8546d74 Removed special handling of backspace and form feed 2023-09-22 01:18:38 +00:00
Nathan Byrd 79a3f4e1ce Handle deleting rows / columns 2023-09-20 23:52:34 +00:00
Nathan Byrd c0c262c971 Added insert and delete rows 2023-09-20 23:30:01 +00:00
Nathan Byrd 826db2d718 Added scrolling. 2023-09-20 23:00:32 +00:00
Nathan Byrd f3c9afc684 Added F and G 2023-09-20 21:40:59 +00:00
Nathan Byrd 372d84f572 Added backspace 2023-09-20 21:23:00 +00:00
Nathan Byrd 8029521399 changed handling of regex 2023-09-20 21:19:03 +00:00
Nathan Byrd 855fabe34d Added additional vt100 codes 2023-09-20 13:44:54 +00:00
Nathan Byrd 5712645299 Added additional characters that change position 2023-09-19 01:39:04 +00:00
Nathan Byrd a99b55abb5 Added support for some non-bracket escape sequences 2023-09-19 01:04:36 +00:00
Nathan Byrd d8f45f9147 Removed unused code 2023-09-18 23:36:27 +00:00
Nathan Byrd 08841528e2 Initial versions of new bansi codes 2023-09-18 23:35:44 +00:00
Nathan Byrd 4d70f07fde Updated node-pty to support new node versions 2023-08-25 15:59:35 -05:00
12 changed files with 878 additions and 734 deletions

View File

@ -7,7 +7,7 @@
"features": {
"ghcr.io/devcontainers/features/python:1": {
"installTools": true,
"version": "latest"
"version": "3.11"
},
"ghcr.io/devcontainers-contrib/features/curl-apt-get:1": {},
"ghcr.io/jungaretti/features/ripgrep:1": {},

View File

@ -11,14 +11,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v2
@ -31,5 +31,5 @@ jobs:
with:
tags: enigmabbs/enigma-bbs:latest
file: docker/Dockerfile
platforms: linux/amd64,linux/arm64
platforms: linux/amd64,linux/arm64,linux/arm/v7
push: true

17
.vscode/launch.json vendored
View File

@ -1,17 +0,0 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"skipFiles": [
"<node_internals>/**"
],
"program": "${workspaceFolder}/main.js"
}
]
}

View File

@ -24,7 +24,7 @@ function ANSIEscapeParser(options) {
this.graphicRendition = {};
this.parseState = {
re: /(?:\x1b\x5b)([?=;0-9]*?)([ABCDHJKfhlmnpsutEFGST])/g, // eslint-disable-line no-control-regex
re: /(?:\x1b)(?:(?:\x5b([?=;0-9]*?)([ABCDEFGfHJKLmMsSTuUYZt@PXhlnpt]))|([78DEHM]))/g, // eslint-disable-line no-control-regex
};
options = miscUtil.valueWithDefault(options, {
@ -77,10 +77,25 @@ function ANSIEscapeParser(options) {
self.clearScreen = function () {
self.column = 1;
self.row = 1;
self.positionUpdated();
self.emit('clear screen');
};
self.positionUpdated = function () {
if(self.row > self.termHeight) {
if(this.savedPosition) {
this.savedPosition.row -= self.row - self.termHeight;
}
self.emit('scroll', self.row - self.termHeight);
self.row = self.termHeight;
}
else if(self.row < 1) {
if(this.savedPosition) {
this.savedPosition.row -= self.row - 1;
}
self.emit('scroll', -(self.row - 1));
self.row = 1;
}
self.emit('position update', self.row, self.column);
};
@ -231,7 +246,7 @@ function ANSIEscapeParser(options) {
self.parseState = {
// ignore anything past EOF marker, if any
buffer: input.split(String.fromCharCode(0x1a), 1)[0],
re: /(?:\x1b\x5b)([?=;0-9]*?)([ABCDHJKfhlmnpsutEFGST])/g, // eslint-disable-line no-control-regex
re: /(?:\x1b)(?:(?:\x5b([?=;0-9]*?)([ABCDEFGfHJKLmMsSTuUYZt@PXhlnpt]))|([78DEHM]))/g, // eslint-disable-line no-control-regex
stop: false,
};
};
@ -271,9 +286,47 @@ function ANSIEscapeParser(options) {
opCode = match[2];
args = match[1].split(';').map(v => parseInt(v, 10)); // convert to array of ints
escape(opCode, args);
// Handle the case where there is no bracket
if(!(_.isNil(match[3]))) {
opCode = match[3];
args = [];
// no bracket
switch(opCode) {
// save cursor position
case '7':
escape('s', args);
break;
// restore cursor position
case '8':
escape('u', args);
break;
// scroll up
case 'D':
escape('S', args);
break;
// move to next line
case 'E':
// functonality is the same as ESC [ E
escape(opCode, args);
break;
// create a tab at current cursor position
case 'H':
literal('\t');
break;
// scroll down
case 'M':
escape('T', args);
break;
}
}
else {
escape(opCode, args);
}
//self.emit('chunk', match[0]);
self.emit('control', match[0], opCode, args);
}
} while (0 !== re.lastIndex);
@ -281,8 +334,8 @@ function ANSIEscapeParser(options) {
if (pos < buffer.length) {
var lastBit = buffer.slice(pos);
// :TODO: check for various ending LF's, not just DOS \r\n
if ('\r\n' === lastBit.slice(-2).toString()) {
// handles either \r\n or \n
if ('\n' === lastBit.slice(-1).toString()) {
switch (self.trailingLF) {
case 'default':
//
@ -290,14 +343,14 @@ function ANSIEscapeParser(options) {
// if we're going to end on termHeight
//
if (this.termHeight === self.row) {
lastBit = lastBit.slice(0, -2);
lastBit = lastBit.slice(0, -1);
}
break;
case 'omit':
case 'no':
case false:
lastBit = lastBit.slice(0, -2);
lastBit = lastBit.slice(0, -1);
break;
}
}
@ -308,48 +361,6 @@ function ANSIEscapeParser(options) {
self.emit('complete');
};
/*
self.parse = function(buffer, savedRe) {
// :TODO: ensure this conforms to ANSI-BBS / CTerm / bansi.txt for movement/etc.
// :TODO: move this to "constants" section @ top
var re = /(?:\x1b\x5b)([\?=;0-9]*?)([ABCDHJKfhlmnpsu])/g;
var pos = 0;
var match;
var opCode;
var args;
// ignore anything past EOF marker, if any
buffer = buffer.split(String.fromCharCode(0x1a), 1)[0];
do {
pos = re.lastIndex;
match = re.exec(buffer);
if(null !== match) {
if(match.index > pos) {
parseMCI(buffer.slice(pos, match.index));
}
opCode = match[2];
args = getArgArray(match[1].split(';'));
escape(opCode, args);
self.emit('chunk', match[0]);
}
} while(0 !== re.lastIndex);
if(pos < buffer.length) {
parseMCI(buffer.slice(pos));
}
self.emit('complete');
};
*/
function escape(opCode, args) {
let arg;
@ -382,6 +393,37 @@ function ANSIEscapeParser(options) {
self.moveCursor(-arg, 0);
break;
// line feed
case 'E':
arg = isNaN(args[0]) ? 1 : args[0];
if(this.row + arg > this.termHeight) {
this.emit('scroll', arg - (this.termHeight - this.row));
self.moveCursor(0, this.termHeight);
}
else {
self.moveCursor(0, arg);
}
break;
// reverse line feed
case 'F':
arg = isNaN(args[0]) ? 1 : args[0];
if(this.row - arg < 1) {
this.emit('scroll', -(arg - this.row));
self.moveCursor(0, 1 - this.row);
}
else {
self.moveCursor(0, -arg);
}
break;
// absolute horizontal cursor position
case 'G':
arg = isNaN(args[0]) ? 1 : args[0];
self.column = Math.max(1, arg);
self.positionUpdated();
break;
case 'f': // horiz & vertical
case 'H': // cursor position
//self.row = args[0] || 1;
@ -392,14 +434,37 @@ function ANSIEscapeParser(options) {
self.positionUpdated();
break;
// save position
case 's':
self.saveCursorPosition();
// erase display/screen
case 'J':
if(isNaN(args[0]) || 0 === args[0]) {
self.emit('erase rows', self.row, self.termHeight);
}
else if (1 === args[0]) {
self.emit('erase rows', 1, self.row);
}
else if (2 === args[0]) {
self.clearScreen();
}
break;
// restore position
case 'u':
self.restoreCursorPosition();
// erase text in line
case 'K':
if(isNaN(args[0]) || 0 === args[0]) {
self.emit('erase columns', self.row, self.column, self.termWidth);
}
else if (1 === args[0]) {
self.emit('erase columns', self.row, 1, self.column);
}
else if (2 === args[0]) {
self.emit('erase columns', self.row, 1, self.termWidth);
}
break;
// insert line
case 'L':
arg = isNaN(args[0]) ? 1 : args[0];
self.emit('insert line', self.row, arg);
break;
// set graphic rendition
@ -471,15 +536,52 @@ function ANSIEscapeParser(options) {
self.emit('sgr update', self.graphicRendition);
break; // m
// :TODO: s, u, K
// erase display/screen
case 'J':
// :TODO: Handle other 'J' types!
if (2 === args[0]) {
self.clearScreen();
}
// save position
case 's':
self.saveCursorPosition();
break;
// Scroll up
case 'S':
arg = isNaN(args[0]) ? 1 : args[0];
self.emit('scroll', arg);
break;
// Scroll down
case 'T':
arg = isNaN(args[0]) ? 1 : args[0];
self.emit('scroll', -arg);
break;
// restore position
case 'u':
self.restoreCursorPosition();
break;
// clear
case 'U':
self.clearScreen();
break;
// delete line
// TODO: how should we handle 'M'?
case 'Y':
arg = isNaN(args[0]) ? 1 : args[0];
self.emit('delete line', self.row, arg);
break;
// back tab
case 'Z':
// calculate previous tabstop
self.column = Math.max( 1, self.column - (self.column % 8 || 8) );
self.positionUpdated();
break;
case '@':
// insert column(s)
arg = isNaN(args[0]) ? 1 : args[0];
self.emit('insert columns', self.row, self.column, arg);
break;
}
}
}

View File

@ -208,17 +208,17 @@ module.exports = class ArchiveUtil {
// pty.js doesn't currently give us a error when things fail,
// so we have this horrible, horrible hack:
let err;
proc.once('data', d => {
proc.onData(d => {
if (_.isString(d) && d.startsWith('execvp(3) failed.')) {
err = Errors.ExternalProcess(`${action} failed: ${d.trim()}`);
}
});
proc.once('exit', exitCode => {
proc.onExit(exitEvent => {
return cb(
exitCode
exitEvent.exitCode
? Errors.ExternalProcess(
`${action} failed with exit code: ${exitCode}`
`${action} failed with exit code: ${exitEvent.exitCode}`
)
: err
);
@ -358,10 +358,10 @@ module.exports = class ArchiveUtil {
output += data;
});
proc.once('exit', exitCode => {
if (exitCode) {
proc.onExit(exitEvent => {
if (exitEvent.exitCode) {
return cb(
Errors.ExternalProcess(`List failed with exit code: ${exitCode}`)
Errors.ExternalProcess(`List failed with exit code: ${exitEvent.exitCode}`)
);
}

View File

@ -316,6 +316,75 @@ function display(client, art, options, cb) {
}
});
// Remove any MCI's that are in erased rows
ansiParser.on('erase row', (startRow, endRow) => {
_.forEach(mciMap, (mciInfo, mapKey) => {
if (mciInfo.position[0] >= startRow && mciInfo.position[0] <= endRow) {
delete mciMap[mapKey];
}
});
});
// Remove any MCI's that are in erased columns
ansiParser.on('erase columns', (row, startCol, endCol) => {
_.forEach(mciMap, (mciInfo, mapKey) => {
if (
mciInfo.position[0] === row &&
mciInfo.position[1] >= startCol &&
mciInfo.position[1] <= endCol
) {
delete mciMap[mapKey];
}
});
});
ansiParser.on('insert columns', (row, startCol, numCols) => {
_.forEach(mciMap, (mciInfo, mapKey) => {
if (mciInfo.position[0] === row && mciInfo.position[1] >= startCol) {
mciInfo.position[1] += numCols;
if(mciInfo.position[1] > client.term.termWidth) {
delete mciMap[mapKey];
}
}
});
});
// Clear the screen, removing any MCI's
ansiParser.on('clear screen', () => {
_.forEach(mciMap, (mciInfo, mapKey) => {
delete mciMap[mapKey];
});
});
ansiParser.on('scroll', (scrollY) => {
_.forEach(mciMap, (mciInfo) => {
mciInfo.position[0] -= scrollY;
});
});
ansiParser.on('insert line', (row, numLines) => {
_.forEach(mciMap, (mciInfo) => {
if (mciInfo.position[0] >= row) {
mciInfo.position[0] += numLines;
}
});
});
ansiParser.on('delete line', (row, numLines) => {
_.forEach(mciMap, (mciInfo, mapKey) => {
if (mciInfo.position[0] >= row) {
if(mciInfo.position[0] < row + numLines) {
// unlike scrolling, the rows are actually gone,
// so we need to delete any MCI's that are in them
delete mciMap[mapKey];
}
else {
mciInfo.position[0] -= numLines;
}
}
});
});
ansiParser.on('literal', literal => client.term.write(literal, false));
ansiParser.on('control', control => client.term.rawWrite(control));

View File

@ -115,9 +115,10 @@ module.exports = class Door {
spawnOptions
);
prePty.once('exit', exitCode => {
prePty.onExit(exitEvent => {
const {exitCode, signal} = exitEvent;
this.client.log.info(
{ exitCode: exitCode },
{ exitCode, signal },
'Door pre-command exited'
);
return callback(null);
@ -167,7 +168,7 @@ module.exports = class Door {
this.doorPty.onData(this.doorDataHandler.bind(this));
this.doorPty.once('close', () => {
this.doorPty.onExit( (/*exitEvent*/) => {
return this.restoreIo(this.doorPty);
});
} else if ('socket' === this.io) {
@ -180,8 +181,9 @@ module.exports = class Door {
);
}
this.doorPty.once('exit', exitCode => {
this.client.log.info({ exitCode: exitCode }, 'Door exited');
this.doorPty.onExit(exitEvent => {
const {exitCode, signal} = exitEvent;
this.client.log.info({ exitCode, signal }, 'Door exited');
if (this.sockServer) {
this.sockServer.close();

View File

@ -167,17 +167,17 @@ class ScheduledEvent {
return cb(e);
}
proc.once('exit', exitCode => {
if (exitCode) {
proc.onExit(exitEvent => {
if (exitEvent.exitCode) {
Log.warn(
{ eventName: this.name, action: this.action, exitCode: exitCode },
{ eventName: this.name, action: this.action, exitCode: exitEvent.exitCode },
'Bad exit code while performing scheduled event action'
);
}
return cb(
exitCode
exitEvent.exitCode
? Errors.ExternalProcess(
`Bad exit code while performing scheduled event action: ${exitCode}`
`Bad exit code while performing scheduled event action: ${exitEvent.exitCode}`
)
: null
);

View File

@ -485,13 +485,10 @@ exports.getModule = class TransferFileModule extends MenuModule {
}
});
externalProc.once('close', () => {
return this.restorePipeAfterExternalProc();
});
externalProc.once('exit', exitCode => {
externalProc.onExit(exitEvent => {
const {exitCode, signal} = exitEvent;
this.client.log.debug(
{ cmd: cmd, args: args, exitCode: exitCode },
{ cmd: cmd, args: args, exitCode, signal },
'Process exited'
);

View File

@ -1,19 +1,25 @@
FROM node:18-buster-slim
FROM --platform=${BUILDPLATFORM:-linux/amd64} node:20-bookworm-slim
ARG TARGETPLATFORM
ARG BUILDPLATFORM
ARG TARGETOS
ARG TARGETBRANCH
LABEL maintainer="dave@force9.org"
ENV NVM_DIR /root/.nvm
ENV DEBIAN_FRONTEND noninteractive
COPY . /enigma-bbs
# Do some installing! (and alot of cleaning up) keeping it in one step for less docker layers
# - if you need to debug i recommend to break the steps with individual RUNs)
# Just copy the package.json so it only needs to build once
COPY package.json /enigma-bbs/
# Install APT and NPM packages
RUN apt-get update \
&& apt-get install -y \
git \
curl \
build-essential \
python \
python3 \
libssl-dev \
lrzsz \
@ -22,9 +28,21 @@ RUN apt-get update \
unrar-free \
p7zip-full \
dos2unix \
&& npm set progress=false && npm config set depth 0 \
&& npm install -g npm@latest \
&& npm install -g pm2 \
&& cd /enigma-bbs && npm install \
&& cd /enigma-bbs && npm install
# Do this after npm install to avoid cache-miss on every code change
COPY . /enigma-bbs
# Then run post source copy steps that have to happen every time
RUN dos2unix /enigma-bbs/docker/bin/docker-entrypoint.sh \
&& apt-get remove dos2unix -y \
&& chmod +x /enigma-bbs/docker/bin/docker-entrypoint.sh \
&& cp -f /enigma-bbs/docker/bin/sexyz /usr/local/bin \
&& cd /enigma-bbs \
&& pm2 start main.js \
&& mkdir -p /enigma-bbs-pre/art \
&& mkdir /enigma-bbs-pre/mods \
@ -32,16 +50,11 @@ RUN apt-get update \
&& cp -rp art/* ../enigma-bbs-pre/art/ \
&& cp -rp mods/* ../enigma-bbs-pre/mods/ \
&& cp -rp config/* ../enigma-bbs-pre/config/ \
&& apt-get remove build-essential python python3 libssl-dev git curl -y \
&& apt-get remove build-essential python3 libssl-dev git curl -y \
&& apt-get autoremove -y \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \
&& apt-get clean
# sexyz
COPY docker/bin/sexyz /usr/local/bin
RUN dos2unix /enigma-bbs/docker/bin/docker-entrypoint.sh && apt-get remove dos2unix -y
RUN chmod +x /enigma-bbs/docker/bin/docker-entrypoint.sh
# enigma storage mounts
VOLUME /enigma-bbs/art
VOLUME /enigma-bbs/config

View File

@ -50,7 +50,7 @@
"minimist": "^1.2.6",
"moment": "2.29.4",
"nntp-server": "3.1.0",
"node-pty": "0.10.1",
"node-pty": "1.0.0",
"nodemailer": "6.7.7",
"otplib": "11.0.1",
"qrcode-generator": "^1.4.4",

1202
yarn.lock

File diff suppressed because it is too large Load Diff