Skip to content

Commit

Permalink
feat: add fontSize option #292
Browse files Browse the repository at this point in the history
  • Loading branch information
billchurch committed Jul 30, 2022
1 parent 6fa65a3 commit 5e78812
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 4 deletions.
4 changes: 4 additions & 0 deletions README.md
Expand Up @@ -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"

* **fontSize** - _integer_ - Size of terminal font. **Default:** "12".

## GET request vars

* **port=** - _integer_ - port of SSH server (defaults to 22)
Expand All @@ -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"

* **fontSize** - _integer_ - Size of terminal font. **Default:** "12".

## Headers

* **allowreplay** - _boolean_ - Allow use of password replay feature, example `allowreplay: true`
Expand Down
2 changes: 1 addition & 1 deletion app/client/public/webssh2.bundle.js

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion app/client/src/js/index.ts
Expand Up @@ -170,7 +170,13 @@ socket.on('connect', () => {

socket.on(
'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;
}
);
Expand Down
7 changes: 6 additions & 1 deletion app/server/routes.js
Expand Up @@ -30,7 +30,7 @@ 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 } = config.terminal;
let { cursorBlink, scrollback, tabStopWidth, bellStyle, fontSize } = config.terminal;

// capture, assign, and validate variables

Expand Down Expand Up @@ -71,6 +71,8 @@ exports.connect = function connect(req, res) {
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 }))
fontSize = req.body.fontSize;
}

if (req.method === 'GET') {
Expand Down Expand Up @@ -99,6 +101,8 @@ exports.connect = function connect(req, res) {
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 }))
fontSize = req.query.fontSize;
}

req.session.ssh = {
Expand All @@ -120,6 +124,7 @@ exports.connect = function connect(req, res) {
scrollback,
tabStopWidth,
bellStyle,
fontSize,
},
allowreplay:
config.options.challengeButton ||
Expand Down
2 changes: 1 addition & 1 deletion app/server/socket.js
Expand Up @@ -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 = true;
socket.emit('setTerminalOpts', socket.request.session.ssh.terminal);
socket.emit('menu');
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}`);
if (socket.request.session.ssh.header.background)
socket.emit('headerBackground', socket.request.session.ssh.header.background);
Expand Down

0 comments on commit 5e78812

Please sign in to comment.