mirror of
https://github.com/Buriburizaem0n/nezha_domains.git
synced 2026-09-19 09:40:12 +00:00
fix(terminal): bound websocket input frames
This commit is contained in:
@@ -14,6 +14,11 @@ import (
|
|||||||
"github.com/nezhahq/nezha/service/singleton"
|
"github.com/nezhahq/nezha/service/singleton"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Allow the frontend's 512 KiB clipboard payload plus xterm's bracketed-paste
|
||||||
|
// control bytes, while keeping the complete tagged message below the 1 MiB
|
||||||
|
// IO stream relay buffer.
|
||||||
|
const terminalWebSocketInputLimit int64 = 512*1024 + 64
|
||||||
|
|
||||||
// Create web ssh terminal
|
// Create web ssh terminal
|
||||||
// @Summary Create web ssh terminal
|
// @Summary Create web ssh terminal
|
||||||
// @Description Create web ssh terminal
|
// @Description Create web ssh terminal
|
||||||
@@ -100,6 +105,7 @@ func terminalStream(c *gin.Context) (any, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, newWsError("%v", err)
|
return nil, newWsError("%v", err)
|
||||||
}
|
}
|
||||||
|
wsConn.SetReadLimit(terminalWebSocketInputLimit)
|
||||||
conn := websocketx.NewConn(wsConn)
|
conn := websocketx.NewConn(wsConn)
|
||||||
pingTransport := newWebsocketPingTransport(conn, wsConn.Close)
|
pingTransport := newWebsocketPingTransport(conn, wsConn.Close)
|
||||||
stopPing := startWebsocketPingTicker(c.Request.Context(), time.Second*10, pingTransport)
|
stopPing := startWebsocketPingTicker(c.Request.Context(), time.Second*10, pingTransport)
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package controller
|
||||||
|
|
||||||
|
import "testing"
|
||||||
|
|
||||||
|
func TestTerminalWebSocketInputLimitAllowsBoundedPaste(t *testing.T) {
|
||||||
|
if terminalWebSocketInputLimit != 512*1024+64 {
|
||||||
|
t.Fatalf("terminal WebSocket input limit = %d, want 512 KiB plus control-byte allowance", terminalWebSocketInputLimit)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
name: "OfficialAdmin"
|
name: "OfficialAdmin"
|
||||||
repository: "https://github.com/nezhahq/admin-frontend"
|
repository: "https://github.com/nezhahq/admin-frontend"
|
||||||
author: "nezhahq"
|
author: "nezhahq"
|
||||||
version: "v2.3.2"
|
version: "v2.3.3"
|
||||||
is_admin: true
|
is_admin: true
|
||||||
is_official: true
|
is_official: true
|
||||||
- path: "user-dist"
|
- path: "user-dist"
|
||||||
|
|||||||
Reference in New Issue
Block a user