Skip to content

Commit edefda2

Browse files
committed
expose last received command
1 parent aed438b commit edefda2

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
@@ -117,6 +117,11 @@ func (c *clientHandler) HasTLSForControl() bool {
117117
return c.controlTLS
118118
}
119119

120+
// GetLastCommand returns the last received command
121+
func (c *clientHandler) GetLastCommand() string {
122+
return c.command
123+
}
124+
120125
// HasTLSForTransfers returns true if the transfer connection is over TLS
121126
func (c *clientHandler) HasTLSForTransfers() bool {
122127
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)