mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-07 06:40:54 +03:00
fix connection limits
an SFTP client can start multiple transfers on a single connection Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
@@ -227,6 +227,12 @@ func (c *scpCommand) getUploadFileData(sizeToRead int64, transfer *transfer) err
|
||||
}
|
||||
|
||||
func (c *scpCommand) handleUploadFile(fs vfs.Fs, resolvedPath, filePath string, sizeToRead int64, isNewFile bool, fileSize int64, requestPath string) error {
|
||||
if err := common.Connections.IsNewTransferAllowed(c.connection.User.Username); err != nil {
|
||||
err := fmt.Errorf("denying file write due to transfer count limits")
|
||||
c.connection.Log(logger.LevelInfo, "denying file write due to transfer count limits")
|
||||
c.sendErrorMessage(nil, err)
|
||||
return err
|
||||
}
|
||||
diskQuota, transferQuota := c.connection.HasSpace(isNewFile, false, requestPath)
|
||||
if !diskQuota.HasSpace || !transferQuota.HasUploadSpace() {
|
||||
err := fmt.Errorf("denying file write due to quota limits")
|
||||
@@ -501,6 +507,13 @@ func (c *scpCommand) sendDownloadFileData(fs vfs.Fs, filePath string, stat os.Fi
|
||||
|
||||
func (c *scpCommand) handleDownload(filePath string) error {
|
||||
c.connection.UpdateLastActivity()
|
||||
|
||||
if err := common.Connections.IsNewTransferAllowed(c.connection.User.Username); err != nil {
|
||||
err := fmt.Errorf("denying file read due to transfer count limits")
|
||||
c.connection.Log(logger.LevelInfo, "denying file read due to transfer count limits")
|
||||
c.sendErrorMessage(nil, err)
|
||||
return err
|
||||
}
|
||||
transferQuota := c.connection.GetTransferQuota()
|
||||
if !transferQuota.HasDownloadSpace() {
|
||||
c.connection.Log(logger.LevelInfo, "denying file read due to quota limits")
|
||||
|
||||
Reference in New Issue
Block a user