コード例 #1
0
        private async Task CommandEpsvAsync(string parameter)
        {
            int port;

            try
            {
                if (string.IsNullOrEmpty(parameter))
                {
                    port = dataConnection.Listen().Port;
                }
                else
                {
                    var protocal = int.Parse(parameter);
                    port = dataConnection.ExtendedListen(protocal);
                }
            }
            catch (FormatException)
            {
                await ReplyAsync(FtpReplyCode.SyntaxErrorInParametersOrArguments, "Protocal ID incorrect.");

                return;
            }
            catch (NotSupportedException)
            {
                var supportedProtocalString =
                    string.Join(",", dataConnection.SupportedPassiveProtocal.Select(x => x.ToString()));
                await ReplyAsync(FtpReplyCode.NotSupportedProtocal, $"Protocal not supported, use({supportedProtocalString})");

                return;
            }
            dataConnectionMode = DataConnectionMode.ExtendedPassive;
            await ReplyAsync(
                FtpReplyCode.EnteringEpsvMode,
                string.Format("Entering extended passive mode (|||{0}|).", port));
        }