From 5a03dbf2a3dc1897fe62309a539639b755c70418 Mon Sep 17 00:00:00 2001 From: Eveldee Date: Sat, 20 Jul 2019 17:50:55 +0200 Subject: [PATCH] Add protection only when necessary --- DearFTP/Connection/Commands/ProtectionCommand.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/DearFTP/Connection/Commands/ProtectionCommand.cs b/DearFTP/Connection/Commands/ProtectionCommand.cs index c7585de..b141392 100644 --- a/DearFTP/Connection/Commands/ProtectionCommand.cs +++ b/DearFTP/Connection/Commands/ProtectionCommand.cs @@ -9,14 +9,22 @@ public void Execute(Session session, FtpStream stream, string alias, string argument) { + var dataConnection = session.DataConnection; + switch (argument.ToUpper()) { case "C": - session.DataConnection.DesactivateTls(); + if (dataConnection.IsTlsProtected) + { + session.DataConnection.DesactivateTls(); + } stream.Send(ResponseCode.OK, "Data protection cleared."); break; case "P": - session.DataConnection.ActivateTls(); + if (!dataConnection.IsTlsProtected) + { + session.DataConnection.ActivateTls(); + } stream.Send(ResponseCode.OK, "Data protection set."); break; default: