From 133d2692c445d3486fcdd931e32f03226a0c8278 Mon Sep 17 00:00:00 2001 From: mmtootmm Date: Wed, 28 Jan 2026 02:48:59 +0900 Subject: [PATCH] Fix/ftp active connection closed (#2164) ftpd: avoid fresh ftp connection being closed --- internal/common/common.go | 2 +- internal/common/common_test.go | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/internal/common/common.go b/internal/common/common.go index c6abbd90..3f0901c1 100644 --- a/internal/common/common.go +++ b/internal/common/common.go @@ -1161,7 +1161,7 @@ func (conns *ActiveConnections) checkIdles() { logger.Debug(conn.GetProtocol(), conn.GetID(), "close idle connection, idle time: %s, username: %q close err: %v", time.Since(conn.GetLastActivity()), conn.GetUsername(), err) }(c) - } else if !c.isAccessAllowed() { + } else if !isUnauthenticatedFTPUser && !c.isAccessAllowed() { defer func(conn ActiveConnection) { err := conn.Disconnect() logger.Info(conn.GetProtocol(), conn.GetID(), "access conditions not met for user: %q close connection err: %v", diff --git a/internal/common/common_test.go b/internal/common/common_test.go index cc85af0d..8566d773 100644 --- a/internal/common/common_test.go +++ b/internal/common/common_test.go @@ -828,11 +828,7 @@ func TestIdleConnections(t *testing.T) { assert.NoError(t, err) assert.Equal(t, Connections.GetActiveSessions(username), 2) - cFTP := NewBaseConnection("id2", ProtocolFTP, "", "", dataprovider.User{ - BaseUser: sdk.BaseUser{ - Status: 1, - }, - }) + cFTP := NewBaseConnection("id2", ProtocolFTP, "", "", dataprovider.User{}) cFTP.lastActivity.Store(time.Now().UnixNano()) fakeConn = &fakeConnection{ BaseConnection: cFTP,