/// <inheritdoc/> public override async Task <IFtpResponse> Process(FtpCommand command, CancellationToken cancellationToken) { try { var address = Address.Parse(command.Argument); if (address == null) { return(new FtpResponse(501, T("Syntax error in parameters or arguments."))); } var feature = await _dataConnectionFeatureFactory.CreateFeatureAsync(command, address, _options.DataPort) .ConfigureAwait(false); var oldFeature = Connection.Features.Get <IFtpDataConnectionFeature>(); try { oldFeature.Dispose(); } catch { // Ignore dispose errors! } Connection.Features.Set(feature); } catch (NotSupportedException ex) { return(new FtpResponse(522, T("Extended port failure - {0}.", ex.Message))); } return(new FtpResponse(200, T("Command okay."))); }
/// <inheritdoc/> public override async Task <IFtpResponse?> Process(FtpCommand command, CancellationToken cancellationToken) { if (Connection.Features.Get <IFtpDataConnectionConfigurationFeature>()?.LimitToEpsv ?? false) { // EPSV ALL was sent from the client return(new FtpResponse( 500, $"Cannot use {command.Name} when EPSV ALL was used before.")); } try { var connectionFeature = Connection.Features.Get <IConnectionFeature>(); var address = Parse(command.Argument, connectionFeature.RemoteEndPoint); if (address == null) { return(new FtpResponse(501, T("Syntax error in parameters or arguments."))); } var feature = await _dataConnectionFeatureFactory.CreateFeatureAsync(command, address, _options.DataPort) .ConfigureAwait(false); var oldFeature = Connection.Features.Get <IFtpDataConnectionFeature>(); try { oldFeature.Dispose(); } catch { // Ignore dispose errors! } Connection.Features.Set(feature); } catch (NotSupportedException ex) { return(new FtpResponse(522, T("Extended port failure - {0}.", ex.Message))); } return(new FtpResponse(200, T("Command okay."))); }