Add SSL/TLS protocol support
This commit is contained in:
@@ -9,6 +9,7 @@ namespace DearFTP.Connection.Commands
|
||||
{
|
||||
public ICommand[] Commands { get; } = new ICommand[]
|
||||
{
|
||||
new AuthCommand(),
|
||||
new ClntCommand(),
|
||||
new CwdCommand(),
|
||||
new DeleteCommand(),
|
||||
@@ -21,6 +22,8 @@ namespace DearFTP.Connection.Commands
|
||||
new OptionsCommand(),
|
||||
new ParentDirectoryCommand(),
|
||||
new PassiveCommand(),
|
||||
new ProtectionBufferSizeCommand(),
|
||||
new ProtectionCommand(),
|
||||
new PwdCommand(),
|
||||
new QuitCommand(),
|
||||
new RenameCommand(),
|
||||
@@ -43,15 +46,21 @@ namespace DearFTP.Connection.Commands
|
||||
}
|
||||
|
||||
var commandExecutor = Commands.FirstOrDefault(x => x.Aliases.Contains(command, StringComparer.OrdinalIgnoreCase));
|
||||
var stream = session.FtpStream;
|
||||
|
||||
if (commandExecutor == null)
|
||||
{
|
||||
session.FtpStream.Send(ResponseCode.NotImplemented, $"Command '{command}' not implemented or invalid");
|
||||
|
||||
stream.Send(ResponseCode.NotImplemented, $"Command '{command}' not implemented or invalid");
|
||||
return;
|
||||
}
|
||||
|
||||
commandExecutor.Execute(session, session.FtpStream, command, argument);
|
||||
if (session.Configuration.Tls.ForceTls && !session.IsTlsProtected && command.ToUpper() != "AUTH")
|
||||
{
|
||||
stream.Send(ResponseCode.InsufficientProtection, "Not protected connection is not allowed on this server.");
|
||||
return;
|
||||
}
|
||||
|
||||
commandExecutor.Execute(session, stream, command, argument);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user