sftpd: refactor connection closing

we have not known bugs with the previous implementation anyway this one
is cleaner: the underlying network connection is directly related with
SFTP/SCP connections.
This should better protect us against buggy clients and edge cases
This commit is contained in:
Nicola Murino
2019-10-10 09:04:17 +02:00
parent 4b5ce3913e
commit 871e2ccbbf
4 changed files with 25 additions and 10 deletions

View File

@@ -5,6 +5,7 @@ import (
"fmt"
"io"
"io/ioutil"
"net"
"os"
"runtime"
"testing"
@@ -446,8 +447,12 @@ func TestSCPCommandHandleErrors(t *testing.T) {
ReadError: readErr,
WriteError: writeErr,
}
server, client := net.Pipe()
defer server.Close()
defer client.Close()
connection := Connection{
channel: &mockSSHChannel,
netConn: client,
}
scpCommand := scpCommand{
connection: connection,
@@ -475,8 +480,12 @@ func TestSCPRecursiveDownloadErrors(t *testing.T) {
ReadError: readErr,
WriteError: writeErr,
}
server, client := net.Pipe()
defer server.Close()
defer client.Close()
connection := Connection{
channel: &mockSSHChannel,
netConn: client,
}
scpCommand := scpCommand{
connection: connection,