@@ -22,8 +22,6 @@ import (
2222 "github.com/pkg/sftp/v2/encoding/ssh/filexfer/openssh"
2323 "github.com/pkg/sftp/v2/internal/pragma"
2424 "github.com/pkg/sftp/v2/internal/sync"
25-
26- "golang.org/x/crypto/ssh"
2725)
2826
2927type result struct {
@@ -579,9 +577,24 @@ func (cl *Client) getDataBuf(size int) []byte {
579577 return hint [:size ] // trim our buffer to length, it might be longer than chunkSize.
580578}
581579
580+ type SSHSession interface {
581+ StdinPipe () (io.WriteCloser , error )
582+ StdoutPipe () (io.Reader , error )
583+ StderrPipe () (io.Reader , error )
584+
585+ RequestSubsystem (subsystem string ) error
586+
587+ Close () error
588+ Wait () error
589+ }
590+
591+ type SSHClient [Session SSHSession ] interface {
592+ NewSession () (Session , error )
593+ }
594+
582595// NewClient creates a new SFTP client on conn.
583596// The context is only used during initialization, and handshake.
584- func NewClient (ctx context.Context , conn * ssh. Client , opts ... ClientOption ) (* Client , error ) {
597+ func NewClient [ CL SSHClient [ SESS ], SESS SSHSession ] (ctx context.Context , conn CL , opts ... ClientOption ) (* Client , error ) {
585598 s , err := conn .NewSession ()
586599 if err != nil {
587600 return nil , err
0 commit comments