mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-06 22:30:56 +03:00
add SCP support
SCP is an experimental feature, we have our own SCP implementation since we can't rely on scp system command to proper handle permissions, quota and user's home dir restrictions. The SCP protocol is quite simple but there is no official docs about it, so we need more testing and feedbacks before enabling it by default. We may not handle some borderline cases or have sneaky bugs. This commit contains some breaking changes to the REST API. SFTPGo API should be stable now and I hope no more breaking changes before the first stable release.
This commit is contained in:
@@ -19,18 +19,21 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
logSender = "sftpd"
|
||||
sftpUploadLogSender = "SFTPUpload"
|
||||
sftpdDownloadLogSender = "SFTPDownload"
|
||||
sftpdRenameLogSender = "SFTPRename"
|
||||
sftpdRmdirLogSender = "SFTPRmdir"
|
||||
sftpdMkdirLogSender = "SFTPMkdir"
|
||||
sftpdSymlinkLogSender = "SFTPSymlink"
|
||||
sftpdRemoveLogSender = "SFTPRemove"
|
||||
operationDownload = "download"
|
||||
operationUpload = "upload"
|
||||
operationDelete = "delete"
|
||||
operationRename = "rename"
|
||||
logSender = "sftpd"
|
||||
logSenderSCP = "scp"
|
||||
uploadLogSender = "Upload"
|
||||
downloadLogSender = "Download"
|
||||
renameLogSender = "Rename"
|
||||
rmdirLogSender = "Rmdir"
|
||||
mkdirLogSender = "Mkdir"
|
||||
symlinkLogSender = "Symlink"
|
||||
removeLogSender = "Remove"
|
||||
operationDownload = "download"
|
||||
operationUpload = "upload"
|
||||
operationDelete = "delete"
|
||||
operationRename = "rename"
|
||||
protocolSFTP = "SFTP"
|
||||
protocolSCP = "SCP"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -86,6 +89,8 @@ type ConnectionStatus struct {
|
||||
ConnectionTime int64 `json:"connection_time"`
|
||||
// Last activity as unix timestamp in milliseconds
|
||||
LastActivity int64 `json:"last_activity"`
|
||||
// Protocol for this connection: SFTP or SCP
|
||||
Protocol string `json:"protocol"`
|
||||
// active uploads/downloads
|
||||
Transfers []connectionTransfer `json:"active_transfers"`
|
||||
}
|
||||
@@ -190,6 +195,7 @@ func GetConnectionsStats() []ConnectionStatus {
|
||||
RemoteAddress: c.RemoteAddr.String(),
|
||||
ConnectionTime: utils.GetTimeAsMsSinceEpoch(c.StartTime),
|
||||
LastActivity: utils.GetTimeAsMsSinceEpoch(c.lastActivity),
|
||||
Protocol: c.protocol,
|
||||
Transfers: []connectionTransfer{},
|
||||
}
|
||||
for _, t := range activeTransfers {
|
||||
@@ -250,9 +256,7 @@ func CheckIdleConnections() {
|
||||
if idleTime > idleTimeout {
|
||||
logger.Debug(logSender, "close idle connection id: %v idle time: %v", c.ID, idleTime)
|
||||
err := c.sshConn.Close()
|
||||
if err != nil {
|
||||
logger.Warn(logSender, "error closing idle connection: %v", err)
|
||||
}
|
||||
logger.Debug(logSender, "idle connection closed id: %v, err: %v", c.ID, err)
|
||||
}
|
||||
}
|
||||
logger.Debug(logSender, "check idle connections ended")
|
||||
|
||||
Reference in New Issue
Block a user