Skip to content
Closed
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
12 changes: 12 additions & 0 deletions client_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package ftpserver

import (
"bufio"
"crypto/tls"
"errors"
"fmt"
"io"
Expand Down Expand Up @@ -51,6 +52,7 @@ var (
errNoTransferConnection = errors.New("unable to open transfer: no transfer connection")
errTLSRequired = errors.New("unable to open transfer: TLS is required")
errInvalidTLSRequirement = errors.New("invalid TLS requirement")
errNonTLSConnection = errors.New("GetTLSCiphersuite called on a nonTLS connection")
)

func getHashMapping() map[string]HASHAlgo {
Expand Down Expand Up @@ -259,6 +261,16 @@ func (c *clientHandler) HasTLSForTransfers() bool {
return c.transferTLS
}

func (c *clientHandler) GetTLSCipherSuite() (uint16, error) {
conn := c.conn
tlsConn, ok := conn.(*tls.Conn)
if !ok {
return 0, errNonTLSConnection
}

return tlsConn.ConnectionState().CipherSuite, nil
}

func (c *clientHandler) SetExtra(extra any) {
c.extra = extra
}
Expand Down
3 changes: 3 additions & 0 deletions driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,9 @@ type ClientContext interface {
// HasTLSForTransfers returns true if the transfer connection is over TLS
HasTLSForTransfers() bool

// GetTlSCipherSuite returns ID
GetTLSCipherSuite() (uint16, error)

// GetLastCommand returns the last received command
GetLastCommand() string

Expand Down
Loading