Skip to content

Commit 2c4781b

Browse files
authored
expose last received command (#197)
1 parent c16c83a commit 2c4781b

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

client_handler.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,11 @@ func (c *clientHandler) HasTLSForControl() bool {
142142
return c.controlTLS
143143
}
144144

145+
// GetLastCommand returns the last received command
146+
func (c *clientHandler) GetLastCommand() string {
147+
return c.command
148+
}
149+
145150
// HasTLSForTransfers returns true if the transfer connection is over TLS
146151
func (c *clientHandler) HasTLSForTransfers() bool {
147152
if c.server.settings.TLSRequired == ImplicitEncryption {

client_handler_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"testing"
77

88
"github.com/secsy/goftp"
9+
"github.com/stretchr/testify/assert"
910
"github.com/stretchr/testify/require"
1011
)
1112

@@ -44,6 +45,11 @@ func TestConcurrency(t *testing.T) {
4445
waitGroup.Wait()
4546
}
4647

48+
func TestLastCommand(t *testing.T) {
49+
cc := clientHandler{}
50+
assert.Empty(t, cc.GetLastCommand())
51+
}
52+
4753
func TestTLSMethods(t *testing.T) {
4854
t.Run("without-tls", func(t *testing.T) {
4955
cc := clientHandler{

0 commit comments

Comments
 (0)