mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-08 23:28:39 +03:00
sshconn: use a generic io.Closer instead of a net.Conn
Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
@@ -19,6 +19,7 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
@@ -899,12 +900,12 @@ func getProxyPolicy(allowed, skipped []func(net.IP) bool, def proxyproto.Policy)
|
||||
// Each SSH connection can open several channels for SFTP or SSH commands
|
||||
type SSHConnection struct {
|
||||
id string
|
||||
conn net.Conn
|
||||
conn io.Closer
|
||||
lastActivity atomic.Int64
|
||||
}
|
||||
|
||||
// NewSSHConnection returns a new SSHConnection
|
||||
func NewSSHConnection(id string, conn net.Conn) *SSHConnection {
|
||||
func NewSSHConnection(id string, conn io.Closer) *SSHConnection {
|
||||
c := &SSHConnection{
|
||||
id: id,
|
||||
conn: conn,
|
||||
|
||||
@@ -592,7 +592,7 @@ func (c *Configuration) AcceptInboundConnection(conn net.Conn, config *ssh.Serve
|
||||
conn.SetDeadline(time.Time{}) //nolint:errcheck
|
||||
go ssh.DiscardRequests(reqs)
|
||||
|
||||
defer conn.Close()
|
||||
defer sconn.Close()
|
||||
|
||||
var user dataprovider.User
|
||||
|
||||
@@ -615,7 +615,7 @@ func (c *Configuration) AcceptInboundConnection(conn net.Conn, config *ssh.Serve
|
||||
|
||||
dataprovider.UpdateLastLogin(&user)
|
||||
|
||||
sshConnection := common.NewSSHConnection(connectionID, conn)
|
||||
sshConnection := common.NewSSHConnection(connectionID, sconn)
|
||||
common.Connections.AddSSHConnection(sshConnection)
|
||||
|
||||
defer common.Connections.RemoveSSHConnection(connectionID)
|
||||
|
||||
Reference in New Issue
Block a user