feat: validate handleResize
feat: validate handleControl
This commit is contained in:
parent
aab1a35bc9
commit
b4cbfb4b46
1 changed files with 30 additions and 12 deletions
|
@ -389,13 +389,27 @@ function handleConnection(socket, config) {
|
||||||
function handleResize(stream, data) {
|
function handleResize(stream, data) {
|
||||||
const { rows, cols } = data
|
const { rows, cols } = data
|
||||||
if (stream) {
|
if (stream) {
|
||||||
debug(`Resizing terminal to ${rows}x${cols}`)
|
let resized = false
|
||||||
sessionState.rows = rows
|
|
||||||
sessionState.cols = cols
|
if (rows != null && validator.isInt(rows.toString())) {
|
||||||
stream.setWindow(rows, cols)
|
sessionState.rows = parseInt(rows, 10)
|
||||||
return
|
resized = true
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cols != null && validator.isInt(cols.toString())) {
|
||||||
|
sessionState.cols = parseInt(cols, 10)
|
||||||
|
resized = true
|
||||||
|
}
|
||||||
|
|
||||||
|
if (resized) {
|
||||||
|
debug(`Resizing terminal to ${sessionState.rows}x${sessionState.cols}`)
|
||||||
|
stream.setWindow(sessionState.rows, sessionState.cols)
|
||||||
|
} else {
|
||||||
|
debug("handleResize: No valid resize dimensions provided")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
console.warn("handleResize: Attempted to resize closed connection")
|
||||||
}
|
}
|
||||||
console.warn("handleResize: Attempted to resize closed connection")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -406,10 +420,14 @@ function handleConnection(socket, config) {
|
||||||
*/
|
*/
|
||||||
function handleControl(socket, stream, data) {
|
function handleControl(socket, stream, data) {
|
||||||
debug(`handleControl: Received control data: ${data}`)
|
debug(`handleControl: Received control data: ${data}`)
|
||||||
if (data === "replayCredentials" && stream) {
|
if (validator.isIn(data, ["replayCredentials", "reauth"]) && stream) {
|
||||||
replayCredentials(socket, stream)
|
if (data === "replayCredentials" && stream) {
|
||||||
} else if (data === "reauth") {
|
replayCredentials(socket, stream)
|
||||||
handleReauth(socket)
|
} else if (data === "reauth") {
|
||||||
|
handleReauth(socket)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
console.warn(`handleControl: Invalid control command received: ${data}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -420,12 +438,12 @@ function handleConnection(socket, config) {
|
||||||
sessionState.term = term
|
sessionState.term = term
|
||||||
debug(`handleTerminal: Set term to ${sessionState.term}`)
|
debug(`handleTerminal: Set term to ${sessionState.term}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rows != null && validator.isInt(rows.toString())) {
|
if (rows != null && validator.isInt(rows.toString())) {
|
||||||
sessionState.rows = parseInt(rows, 10)
|
sessionState.rows = parseInt(rows, 10)
|
||||||
debug(`handleTerminal: Set rows to ${sessionState.rows}`)
|
debug(`handleTerminal: Set rows to ${sessionState.rows}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cols != null && validator.isInt(cols.toString())) {
|
if (cols != null && validator.isInt(cols.toString())) {
|
||||||
sessionState.cols = parseInt(cols, 10)
|
sessionState.cols = parseInt(cols, 10)
|
||||||
debug(`handleTerminal: Set cols to ${sessionState.cols}`)
|
debug(`handleTerminal: Set cols to ${sessionState.cols}`)
|
||||||
|
|
Loading…
Reference in a new issue