From f81d09d540a3421efe80f8388965491575d35617 Mon Sep 17 00:00:00 2001 From: Eveldee Date: Sat, 27 Jul 2019 20:26:10 +0200 Subject: [PATCH] Add EPSV command --- .../Connection/Commands/CommandsDispatcher.cs | 1 + .../Commands/ExtendedPassiveCommand.cs | 26 +++++++++++++++++++ DearFTP/Connection/Commands/HelpCommand.cs | 1 + 3 files changed, 28 insertions(+) create mode 100644 DearFTP/Connection/Commands/ExtendedPassiveCommand.cs diff --git a/DearFTP/Connection/Commands/CommandsDispatcher.cs b/DearFTP/Connection/Commands/CommandsDispatcher.cs index 20cb3f1..5abb58d 100644 --- a/DearFTP/Connection/Commands/CommandsDispatcher.cs +++ b/DearFTP/Connection/Commands/CommandsDispatcher.cs @@ -12,6 +12,7 @@ namespace DearFTP.Connection.Commands new ClntCommand(), new CwdCommand(), new DeleteCommand(), + new ExtendedPassiveCommand(), new HelpCommand(), new FeaturesCommand(), new FileModificationTimeCommand(), diff --git a/DearFTP/Connection/Commands/ExtendedPassiveCommand.cs b/DearFTP/Connection/Commands/ExtendedPassiveCommand.cs new file mode 100644 index 0000000..3782b36 --- /dev/null +++ b/DearFTP/Connection/Commands/ExtendedPassiveCommand.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace DearFTP.Connection.Commands +{ + class ExtendedPassiveCommand : ICommand + { + public string[] Aliases { get; } = new string[] + { + "EPSV" + }; + + public void Execute(Session session, FtpStream stream, string alias, string argument) + { + session.DataConnection.Create(); + + int port = session.DataConnection.Port; + + stream.Send(ResponseCode.ExtendedPassiveMode, $"Entering Extended Passive Mode (|||{port}|)"); + + session.DataConnection.AcceptClient(); + } + } +} diff --git a/DearFTP/Connection/Commands/HelpCommand.cs b/DearFTP/Connection/Commands/HelpCommand.cs index dcfa267..f071722 100644 --- a/DearFTP/Connection/Commands/HelpCommand.cs +++ b/DearFTP/Connection/Commands/HelpCommand.cs @@ -22,6 +22,7 @@ "CDUP", "CWD", "DELE", + "EPSV", "FEAT", "HELP", "LIST",