feat: add fontSize option #292

This commit is contained in:
Bill Church 2022-07-30 20:13:36 +00:00
parent 6fa65a3f85
commit 5e78812974
5 changed files with 19 additions and 4 deletions

View file

@ -107,6 +107,8 @@ 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" * **bellStyle** - _string_ - Style of terminal bell: ("sound"|"none"). **Default:** "sound". **Enforced Values:** "sound", "none"
* **fontSize** - _integer_ - Size of terminal font. **Default:** "12".
## GET request vars ## GET request vars
* **port=** - _integer_ - port of SSH server (defaults to 22) * **port=** - _integer_ - port of SSH server (defaults to 22)
@ -127,6 +129,8 @@ 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" * **bellStyle** - _string_ - Style of terminal bell: ("sound"|"none"). **Default:** "sound". **Enforced Values:** "sound", "none"
* **fontSize** - _integer_ - Size of terminal font. **Default:** "12".
## Headers ## Headers
* **allowreplay** - _boolean_ - Allow use of password replay feature, example `allowreplay: true` * **allowreplay** - _boolean_ - Allow use of password replay feature, example `allowreplay: true`

File diff suppressed because one or more lines are too long

View file

@ -170,7 +170,13 @@ socket.on('connect', () => {
socket.on( socket.on(
'setTerminalOpts', 'setTerminalOpts',
(data: { cursorBlink: any; scrollback: any; tabStopWidth: any; bellStyle: any }) => { (data: {
cursorBlink: boolean;
scrollback: number;
tabStopWidth: number;
bellStyle: 'none' | 'sound';
fontSize: number;
}) => {
term.options = data; term.options = data;
} }
); );

View file

@ -30,7 +30,7 @@ exports.connect = function connect(req, res) {
let { host, port } = config.ssh; let { host, port } = config.ssh;
let { text: header, background: headerBackground } = config.header; let { text: header, background: headerBackground } = config.header;
let { term: sshterm, readyTimeout } = config.ssh; let { term: sshterm, readyTimeout } = config.ssh;
let { cursorBlink, scrollback, tabStopWidth, bellStyle } = config.terminal; let { cursorBlink, scrollback, tabStopWidth, bellStyle, fontSize } = config.terminal;
// capture, assign, and validate variables // capture, assign, and validate variables
@ -71,6 +71,8 @@ exports.connect = function connect(req, res) {
validator.isInt(`${req.body.readyTimeout}`, { min: 1, max: 300000 }) validator.isInt(`${req.body.readyTimeout}`, { min: 1, max: 300000 })
) )
readyTimeout = req.body.readyTimeout; readyTimeout = req.body.readyTimeout;
if (req.body.fontSize && validator.isInt(`${req.body.fontSize}`, { min: 1, max: 300000 }))
fontSize = req.body.fontSize;
} }
if (req.method === 'GET') { if (req.method === 'GET') {
@ -99,6 +101,8 @@ exports.connect = function connect(req, res) {
validator.isInt(`${req.query.readyTimeout}`, { min: 1, max: 300000 }) validator.isInt(`${req.query.readyTimeout}`, { min: 1, max: 300000 })
) )
readyTimeout = req.query.readyTimeout; readyTimeout = req.query.readyTimeout;
if (req.query?.fontSize && validator.isInt(`${req.query.fontSize}`, { min: 1, max: 300000 }))
fontSize = req.query.fontSize;
} }
req.session.ssh = { req.session.ssh = {
@ -120,6 +124,7 @@ exports.connect = function connect(req, res) {
scrollback, scrollback,
tabStopWidth, tabStopWidth,
bellStyle, bellStyle,
fontSize,
}, },
allowreplay: allowreplay:
config.options.challengeButton || config.options.challengeButton ||

View file

@ -115,9 +115,9 @@ module.exports = function appSocket(socket) {
`LOGIN user=${socket.request.session.username} from=${socket.handshake.address} host=${socket.request.session.ssh.host}:${socket.request.session.ssh.port}` `LOGIN user=${socket.request.session.username} from=${socket.handshake.address} host=${socket.request.session.ssh.host}:${socket.request.session.ssh.port}`
); );
login = true; login = true;
socket.emit('setTerminalOpts', socket.request.session.ssh.terminal);
socket.emit('menu'); socket.emit('menu');
socket.emit('allowreauth', socket.request.session.ssh.allowreauth); socket.emit('allowreauth', socket.request.session.ssh.allowreauth);
socket.emit('setTerminalOpts', socket.request.session.ssh.terminal);
socket.emit('title', `ssh://${socket.request.session.ssh.host}`); socket.emit('title', `ssh://${socket.request.session.ssh.host}`);
if (socket.request.session.ssh.header.background) if (socket.request.session.ssh.header.background)
socket.emit('headerBackground', socket.request.session.ssh.header.background); socket.emit('headerBackground', socket.request.session.ssh.header.background);