Class FtpConnection
This class represents a FTP connection.
Implements
Inherited Members
Namespace: FubarDev.FtpServer
Assembly: FubarDev.FtpServer.dll
Syntax
public sealed class FtpConnection : FtpConnectionContext, IFtpConnection, IConnectionFeature, IDisposable, IObservable<IFtpConnectionEvent>, IFtpConnectionEventHost
  Constructors
| Improve this Doc View SourceFtpConnection(TcpSocketClientAccessor, IOptions<FtpConnectionOptions>, IOptions<PortCommandOptions>, IFtpConnectionAccessor, IFtpCatalogLoader, IServerCommandExecutor, IServiceProvider, SecureDataConnectionWrapper, ISslStreamWrapperFactory, Nullable<ILogger<FtpConnection>>, Nullable<ILoggerFactory>)
Initializes a new instance of the FtpConnection class.
Declaration
public FtpConnection(TcpSocketClientAccessor socketAccessor, IOptions<FtpConnectionOptions> options, IOptions<PortCommandOptions> portOptions, IFtpConnectionAccessor connectionAccessor, IFtpCatalogLoader catalogLoader, IServerCommandExecutor serverCommandExecutor, IServiceProvider serviceProvider, SecureDataConnectionWrapper secureDataConnectionWrapper, ISslStreamWrapperFactory sslStreamWrapperFactory, ILogger<FtpConnection>? logger = default(ILogger<FtpConnection>? ), ILoggerFactory? loggerFactory = default(ILoggerFactory? ))
  Parameters
| Type | Name | Description | 
|---|---|---|
| TcpSocketClientAccessor | socketAccessor | The accessor to get the socket used to communicate with the client.  | 
      
| IOptions<FtpConnectionOptions> | options | The options for the FTP connection.  | 
      
| IOptions<PortCommandOptions> | portOptions | The   | 
      
| IFtpConnectionAccessor | connectionAccessor | The accessor to get the connection that is active during the Process(FtpCommand, CancellationToken) method execution.  | 
      
| IFtpCatalogLoader | catalogLoader | The catalog loader for the FTP server.  | 
      
| IServerCommandExecutor | serverCommandExecutor | The executor for server commands.  | 
      
| IServiceProvider | serviceProvider | The service provider for the connection.  | 
      
| SecureDataConnectionWrapper | secureDataConnectionWrapper | Wraps a data connection into an SSL stream.  | 
      
| ISslStreamWrapperFactory | sslStreamWrapperFactory | The SSL stream wrapper factory.  | 
      
| Nullable<ILogger<FtpConnection>> | logger | The logger for the FTP connection.  | 
      
| Nullable<ILoggerFactory> | loggerFactory | The logger factory.  | 
      
Properties
| Improve this Doc View SourceConnectionId
Gets or sets the connection identifier.
Declaration
public override string ConnectionId { get; set; }
  Property Value
| Type | Description | 
|---|---|
| String | 
Overrides
| Improve this Doc View SourceConnectionServices
Gets the connection services.
Declaration
public IServiceProvider ConnectionServices { get; }
  Property Value
| Type | Description | 
|---|---|
| IServiceProvider | 
Data
Gets the FTP connection data.
Declaration
[Obsolete("Query the information using the Features property instead.")]
public FtpConnectionData Data { get; }
  Property Value
| Type | Description | 
|---|---|
| FtpConnectionData | 
Encoding
Gets or sets the encoding for the LIST/NLST commands.
Declaration
[Obsolete("Query the information using the IEncodingFeature instead.")]
public Encoding Encoding { get; set; }
  Property Value
| Type | Description | 
|---|---|
| Encoding | 
Features
Gets the feature collection.
Declaration
public override IFeatureCollection Features { get; }
  Property Value
| Type | Description | 
|---|---|
| IFeatureCollection | 
Overrides
| Improve this Doc View SourceIsSecure
Gets a value indicating whether this is a secure connection.
Declaration
[Obsolete("Not needed anymore.")]
public bool IsSecure { get; }
  Property Value
| Type | Description | 
|---|---|
| Boolean | 
LocalEndPoint
Gets the local end point.
Declaration
[Obsolete("Query the information using the IConnectionFeature instead.")]
public IPEndPoint LocalEndPoint { get; }
  Property Value
| Type | Description | 
|---|---|
| IPEndPoint | 
Log
Gets the FTP connection logger.
Declaration
[Obsolete("Use your own logger instead of the one from the connection.")]
public ILogger? Log { get; }
  Property Value
| Type | Description | 
|---|---|
| Nullable<ILogger> | 
OriginalStream
Gets the control connection stream.
Declaration
[Obsolete("Query the information using the ISecureConnectionFeature instead.")]
public Stream OriginalStream { get; }
  Property Value
| Type | Description | 
|---|---|
| Stream | 
RemoteAddress
Gets the remote address of the client.
Declaration
[Obsolete("Query the information using the IConnectionFeature instead - and use the RemoteEndPoint property.")]
public Address RemoteAddress { get; }
  Property Value
| Type | Description | 
|---|---|
| Address | 
RemoteEndPoint
Gets the remote end point.
Declaration
[Obsolete("Query the information using the IConnectionFeature instead.")]
public IPEndPoint RemoteEndPoint { get; }
  Property Value
| Type | Description | 
|---|---|
| IPEndPoint | 
SocketStream
Gets or sets the control connection stream.
Declaration
[Obsolete("Not needed anymore.")]
public Stream SocketStream { get; set; }
  Property Value
| Type | Description | 
|---|---|
| Stream | 
Methods
| Improve this Doc View SourceCreateEncryptedStream(Stream)
Create an encrypted stream.
Declaration
[Obsolete("The data connection returned by OpenDataConnection is already encrypted.")]
public Task<Stream> CreateEncryptedStream(Stream unencryptedStream)
  Parameters
| Type | Name | Description | 
|---|---|---|
| Stream | unencryptedStream | The stream to encrypt.  | 
      
Returns
| Type | Description | 
|---|---|
| Task<Stream> | The encrypted stream.  | 
      
Dispose()
Declaration
public void Dispose()
  OpenDataConnectionAsync(Nullable<TimeSpan>, CancellationToken)
Creates a response socket for e.g. LIST/NLST.
Declaration
public Task<IFtpDataConnection> OpenDataConnectionAsync(TimeSpan? timeout, CancellationToken cancellationToken)
  Parameters
| Type | Name | Description | 
|---|---|---|
| Nullable<TimeSpan> | timeout | The timeout for establishing a data connection.  | 
      
| CancellationToken | cancellationToken | The cancellation token.  | 
      
Returns
| Type | Description | 
|---|---|
| Task<IFtpDataConnection> | The data connection.  | 
      
PublishEvent(IFtpConnectionEvent)
Publish the event.
Declaration
public void PublishEvent(IFtpConnectionEvent evt)
  Parameters
| Type | Name | Description | 
|---|---|---|
| IFtpConnectionEvent | evt | The event to publish.  | 
      
StartAsync()
Starts processing of messages for this connection.
Declaration
public Task StartAsync()
  Returns
| Type | Description | 
|---|---|
| Task | The task.  | 
      
StopAsync()
Closes the connection.
Declaration
public Task StopAsync()
  Returns
| Type | Description | 
|---|---|
| Task | The task.  | 
      
Subscribe(IObserver<IFtpConnectionEvent>)
Declaration
public IDisposable Subscribe(IObserver<IFtpConnectionEvent> observer)
  Parameters
| Type | Name | Description | 
|---|---|---|
| IObserver<IFtpConnectionEvent> | observer | 
Returns
| Type | Description | 
|---|---|
| IDisposable | 
WriteAsync(IFtpResponse, CancellationToken)
Writes a FTP response to a client.
Declaration
[Obsolete("Use the IConnectionFeature.ServerCommandWriter instead.")]
public Task WriteAsync(IFtpResponse response, CancellationToken cancellationToken)
  Parameters
| Type | Name | Description | 
|---|---|---|
| IFtpResponse | response | The response to write to the client.  | 
      
| CancellationToken | cancellationToken | The cancellation token.  | 
      
Returns
| Type | Description | 
|---|---|
| Task | The task.  | 
      
WriteAsync(String, CancellationToken)
Writes response to a client.
Declaration
[Obsolete("Use the IConnectionFeature.ServerCommandWriter instead.")]
public Task WriteAsync(string response, CancellationToken cancellationToken)
  Parameters
| Type | Name | Description | 
|---|---|---|
| String | response | The response to write to the client.  | 
      
| CancellationToken | cancellationToken | The cancellation token.  | 
      
Returns
| Type | Description | 
|---|---|
| Task | The task.  | 
      
Events
| Improve this Doc View SourceClosed
Gets or sets the event handler that is triggered when the connection is closed.
Declaration
public event EventHandler? Closed
  Event Type
| Type | Description | 
|---|---|
| Nullable<EventHandler> |