diff --git a/README.md b/README.md index 3b891727..bbbe8d94 100644 --- a/README.md +++ b/README.md @@ -107,7 +107,13 @@ docker run --name webssh2 -d -p 2222:2222 -v `pwd`/app/config.json:/usr/src/conf * **bellStyle** - _string_ - Style of terminal bell: ("sound"|"none"). **Default:** "sound". **Enforced Values:** "sound", "none" -* **fontSize** - _integer_ - Size of terminal font. **Default:** "12". +* **fontSize** - _number_ - Size of terminal font. **Default:** 12 + +* **fontFamily** - _string_ - Font family + +* **letterSpacing** - _number_ - Letter spacing + +* **lineHeight** - _number_ - Line height ## GET request vars @@ -129,7 +135,13 @@ docker run --name webssh2 -d -p 2222:2222 -v `pwd`/app/config.json:/usr/src/conf * **bellStyle** - _string_ - Style of terminal bell: ("sound"|"none"). **Default:** "sound". **Enforced Values:** "sound", "none" -* **fontSize** - _integer_ - Size of terminal font. **Default:** "12". +* **fontSize** - _number_ - Size of terminal font. **Default:** "12" + +* **fontFamily** - _string_ - Font family + +* **letterSpacing** - _number_ - Letter spacing + +* **lineHeight** - _integer_ - Line height ## Headers @@ -174,7 +186,13 @@ docker run --name webssh2 -d -p 2222:2222 -v `pwd`/app/config.json:/usr/src/conf * **terminal.bellStyle** - _string_ - Style of terminal bell: (sound|none). **Default:** "sound". -* **terminal.fontSize** - _integer_ - Size of terminal font. **Default:** 14. +* **terminal.fontSize** - _number_ - Size of terminal font. **Default:** 14. + +* **terminal.fontFamily** - _string_ - Font family + +* **terminal.letterSpacing** - _number_ - Letter spacing + +* **terminal.lineHeight** - _number_ - Line height * **header.text** - _string_ - Specify header text, defaults to `My Header` but may also be set to `null`. When set to `null` no header bar will be displayed on the client. diff --git a/app/client/src/js/index.ts b/app/client/src/js/index.ts index 11da4153..1dd6b60a 100644 --- a/app/client/src/js/index.ts +++ b/app/client/src/js/index.ts @@ -176,6 +176,9 @@ socket.on( tabStopWidth: number; bellStyle: 'none' | 'sound'; fontSize: number; + fontFamily: string; + letterSpacing: number; + lineHeight: number; }) => { term.options = data; } diff --git a/app/package-lock.json b/app/package-lock.json index 66312f21..9a6adb94 100644 --- a/app/package-lock.json +++ b/app/package-lock.json @@ -1,12 +1,12 @@ { "name": "webssh2", - "version": "0.4.7-alpha.1", + "version": "0.4.7-alpha.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "webssh2", - "version": "0.4.7-alpha.1", + "version": "0.4.7-alpha.2", "license": "SEE LICENSE IN FILE - LICENSE", "dependencies": { "basic-auth": "~2.0.1", diff --git a/app/package.json b/app/package.json index 82bc31f1..1db1f2b9 100644 --- a/app/package.json +++ b/app/package.json @@ -1,6 +1,6 @@ { "name": "webssh2", - "version": "0.4.7-alpha.1", + "version": "0.4.7-alpha.2", "ignore": [ ".gitignore" ], diff --git a/app/server/routes.js b/app/server/routes.js index 6b17093c..52767426 100644 --- a/app/server/routes.js +++ b/app/server/routes.js @@ -30,7 +30,16 @@ exports.connect = function connect(req, res) { let { host, port } = config.ssh; let { text: header, background: headerBackground } = config.header; let { term: sshterm, readyTimeout } = config.ssh; - let { cursorBlink, scrollback, tabStopWidth, bellStyle, fontSize } = config.terminal; + let { + cursorBlink, + scrollback, + tabStopWidth, + bellStyle, + fontSize, + fontFamily, + letterSpacing, + lineHeight, + } = config.terminal; // capture, assign, and validate variables @@ -50,59 +59,92 @@ exports.connect = function connect(req, res) { if (req.body.port && validator.isInt(`${req.body.port}`, { min: 1, max: 65535 })) port = req.body.port; + if (req.body.header) header = req.body.header; + if (req.body.headerBackground) { headerBackground = req.body.headerBackground; console.log(`background: ${req.body.headerBackground}`); } + if (req.body.sshterm && /^(([a-z]|[A-Z]|\d|[!^(){}\-_~])+)?\w$/.test(req.body.sshterm)) sshterm = req.body.sshterm; + if (req.body.cursorBlink && validator.isBoolean(`${req.body.cursorBlink}`)) cursorBlink = parseBool(req.body.cursorBlink); + if (req.body.scrollback && validator.isInt(`${req.body.scrollback}`, { min: 1, max: 200000 })) scrollback = req.body.scrollback; - if (req.body.tabStopWidth) tabStopWidth = req.body.tabStopWidth; + if (req.body.tabStopWidth && validator.isInt(`${req.body.tabStopWidth}`, { min: 1, max: 100 })) tabStopWidth = req.body.tabStopWidth; + if (req.body.bellStyle && ['sound', 'none'].indexOf(req.body.bellStyle) > -1) bellStyle = req.body.bellStyle; + if ( req.body.readyTimeout && validator.isInt(`${req.body.readyTimeout}`, { min: 1, max: 300000 }) ) readyTimeout = req.body.readyTimeout; - if (req.body.fontSize && validator.isInt(`${req.body.fontSize}`, { min: 1, max: 300000 })) + + if (req.body.fontSize && validator.isNumeric(`${req.body.fontSize}`)) fontSize = req.body.fontSize; + + if (req.body.fontFamily) fontFamily = req.body.fontFamily; + + if (req.body.letterSpacing && validator.isNumeric(`${req.body.letterSpacing}`)) + letterSpacing = req.body.letterSpacing; + + if (req.body.lineHeight && validator.isNumeric(`${req.body.lineHeight}`)) + lineHeight = req.body.lineHeight; } if (req.method === 'GET') { if (req.query?.port && validator.isInt(`${req.query.port}`, { min: 1, max: 65535 })) port = req.query.port; + if (req.query?.header) header = req.query.header; + if (req.query?.headerBackground) headerBackground = req.query.headerBackground; + if (req.query?.sshterm && /^(([a-z]|[A-Z]|\d|[!^(){}\-_~])+)?\w$/.test(req.query.sshterm)) sshterm = req.query.sshterm; + if (req.query?.cursorBlink && validator.isBoolean(`${req.query.cursorBlink}`)) cursorBlink = parseBool(req.query.cursorBlink); + if ( req.query?.scrollback && validator.isInt(`${req.query.scrollback}`, { min: 1, max: 200000 }) ) scrollback = req.query.scrollback; + if ( req.query?.tabStopWidth && validator.isInt(`${req.query.tabStopWidth}`, { min: 1, max: 100 }) ) tabStopWidth = req.query.tabStopWidth; + if (req.query?.bellStyle && ['sound', 'none'].indexOf(req.query.bellStyle) > -1) bellStyle = req.query.bellStyle; + if ( req.query?.readyTimeout && validator.isInt(`${req.query.readyTimeout}`, { min: 1, max: 300000 }) ) readyTimeout = req.query.readyTimeout; - if (req.query?.fontSize && validator.isInt(`${req.query.fontSize}`, { min: 1, max: 300000 })) + + if (req.query?.fontSize && validator.isNumeric(`${req.query.fontSize}`)) fontSize = req.query.fontSize; + + if (req.query?.fontFamily) fontFamily = req.query.fontFamily; + + if (req.query?.lineHeight && validator.isNumeric(`${req.query.lineHeight}`)) + lineHeight = req.query.lineHeight; + + if (req.query?.letterSpacing && validator.isNumeric(`${req.query.letterSpacing}`)) + letterSpacing = req.query.letterSpacing; } req.session.ssh = { @@ -125,6 +167,9 @@ exports.connect = function connect(req, res) { tabStopWidth, bellStyle, fontSize, + fontFamily, + letterSpacing, + lineHeight, }, allowreplay: config.options.challengeButton ||