Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions internal/sshhandler/channel_pair.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ func (c *SSHChannelPair) serve() {
onPtyRequest: func(req ptyReq) {
// Set the asciinema header with the pty request details only once
c.ptyRequestOnce.Do(func() {
asciinemaHeader.Width = int(req.Columns)
asciinemaHeader.Height = int(req.Rows)
asciinemaHeader.Width = int(req.WidthColumns)
asciinemaHeader.Height = int(req.HeightRows)
})
},
onWindowChange: func(req windowChangeReq) {
Expand All @@ -116,7 +116,7 @@ func (c *SSHChannelPair) serve() {
return
}

if err := r.WriteResizeEvent(int(req.Columns), int(req.Rows)); err != nil {
if err := r.WriteResizeEvent(int(req.WidthColumns), int(req.HeightRows)); err != nil {
c.logger.Error("failed to write resize event", zap.Error(err))
}
},
Expand Down
4 changes: 2 additions & 2 deletions internal/sshhandler/channel_pair_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func TestSSHChannelPair_serve_Success(t *testing.T) {
// Send pty-req request
ptyRequest := &mockSSHRequest{
Type: "pty-req",
Payload: ssh.Marshal(ptyReq{Columns: 80, Rows: 24}),
Payload: ssh.Marshal(ptyReq{WidthColumns: 80, HeightRows: 24}),
WantReply: true,
}
ptyRequest.On("Reply", true, []byte(nil)).Return(nil)
Expand Down Expand Up @@ -159,7 +159,7 @@ func TestSSHChannelPair_serve_Success(t *testing.T) {
// Send window-change request
windowChangeRequest := &mockSSHRequest{
Type: "window-change",
Payload: ssh.Marshal(windowChangeReq{Columns: 100, Rows: 44}),
Payload: ssh.Marshal(windowChangeReq{WidthColumns: 100, HeightRows: 44}),
WantReply: false,
}
windowChangeRequest.On("Reply", false, []byte(nil)).Return(nil)
Expand Down
20 changes: 10 additions & 10 deletions internal/sshhandler/request_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,12 @@ type SSHRequestHandlerFlushTrigger struct {
// SSH pty request structure
// see: https://datatracker.ietf.org/doc/html/rfc4254#section-6.2
type ptyReq struct {
Term string
Columns uint32
Rows uint32
Width uint32
Height uint32
Modelist string
Term string
WidthColumns uint32
HeightRows uint32
WidthPixels uint32
HeightPixels uint32
Modelist string
}

// SSH exec request structure
Expand All @@ -95,10 +95,10 @@ type subsystemReq struct {
// SSH window-change request structure
// see: https://datatracker.ietf.org/doc/html/rfc4254#section-6.7
type windowChangeReq struct {
Columns uint32
Rows uint32
Width uint32
Height uint32
WidthColumns uint32
HeightRows uint32
WidthPixels uint32
HeightPixels uint32
}

// RequestHandler defines the interface for handling SSH channel requests.
Expand Down
28 changes: 14 additions & 14 deletions internal/sshhandler/request_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ import (

func createPtyRequestPayload() []byte {
ptyReq := ptyReq{
Term: "xterm-256color",
Columns: 80,
Rows: 24,
Width: 640,
Height: 480,
Modelist: "",
Term: "xterm-256color",
WidthColumns: 80,
HeightRows: 24,
WidthPixels: 640,
HeightPixels: 480,
Modelist: "",
}
payload := ssh.Marshal(ptyReq)

Expand All @@ -50,10 +50,10 @@ func createSubsystemRequestPayload(name string) []byte {

func createWindowChangeRequestPayload() []byte {
windowChangeReq := windowChangeReq{
Columns: 80,
Rows: 24,
Width: 640,
Height: 480,
WidthColumns: 80,
HeightRows: 24,
WidthPixels: 640,
HeightPixels: 480,
}
payload := ssh.Marshal(windowChangeReq)

Expand Down Expand Up @@ -106,8 +106,8 @@ func TestSSHRequestHandler_handleRequests_PtyRequest(t *testing.T) {

// Verify pty request was processed
assert.Equal(t, "xterm-256color", capturedPtyReq.Term)
assert.Equal(t, uint32(80), capturedPtyReq.Columns)
assert.Equal(t, uint32(24), capturedPtyReq.Rows)
assert.Equal(t, uint32(80), capturedPtyReq.WidthColumns)
assert.Equal(t, uint32(24), capturedPtyReq.HeightRows)

mockChannel.AssertExpectations(t)

Expand Down Expand Up @@ -305,8 +305,8 @@ func TestSSHRequestHandler_handleRequests_WindowChangeRequest(t *testing.T) {
<-signals.finished

// Verify window-change request was processed
assert.Equal(t, uint32(80), capturedWindowChangeReq.Columns)
assert.Equal(t, uint32(24), capturedWindowChangeReq.Rows)
assert.Equal(t, uint32(80), capturedWindowChangeReq.WidthColumns)
assert.Equal(t, uint32(24), capturedWindowChangeReq.HeightRows)

// Assert that Reply was NOT called since WantReply is false
mockReq.AssertNotCalled(t, "Reply")
Expand Down