Add protection only when necessary

This commit is contained in:
2019-07-20 17:50:55 +02:00
parent 94431aebb8
commit 5a03dbf2a3

View File

@@ -9,14 +9,22 @@
public void Execute(Session session, FtpStream stream, string alias, string argument) public void Execute(Session session, FtpStream stream, string alias, string argument)
{ {
var dataConnection = session.DataConnection;
switch (argument.ToUpper()) switch (argument.ToUpper())
{ {
case "C": case "C":
session.DataConnection.DesactivateTls(); if (dataConnection.IsTlsProtected)
{
session.DataConnection.DesactivateTls();
}
stream.Send(ResponseCode.OK, "Data protection cleared."); stream.Send(ResponseCode.OK, "Data protection cleared.");
break; break;
case "P": case "P":
session.DataConnection.ActivateTls(); if (!dataConnection.IsTlsProtected)
{
session.DataConnection.ActivateTls();
}
stream.Send(ResponseCode.OK, "Data protection set."); stream.Send(ResponseCode.OK, "Data protection set.");
break; break;
default: default: