This class represents a FTP connection
Inheritance: IDisposable
Exemplo n.º 1
0
 public FtpLogForNLog(FtpConnection connection)
 {
     _logger = LogManager.GetLogger("FubarDev.FtpServer.FtpConnection");
     _remoteAddress = connection.RemoteAddress.ToString(true);
     _remoteIp = connection.RemoteAddress.IpAddress;
     _remotePort = connection.RemoteAddress.IpPort;
 }
 /// <inheritdoc/>
 public IEnumerable<FtpCommandHandler> CreateCommandHandlers(FtpConnection connection)
 {
     return
         from asm in _assemblies
         from type in asm.DefinedTypes
         where !type.IsAbstract && type.IsSubclassOf(typeof(FtpCommandHandler))
         select (FtpCommandHandler)Activator.CreateInstance(type.AsType(), connection);
 }
 /// <inheritdoc/>
 public IEnumerable<FtpCommandHandlerExtension> CreateCommandHandlerExtensions(FtpConnection connection)
 {
     foreach (var asm in _assemblies)
     {
         foreach (var type in asm.DefinedTypes)
         {
             if (!type.IsAbstract && type.IsSubclassOf(typeof(FtpCommandHandlerExtension)) && type.AsType() != typeof(GenericFtpCommandHandlerExtension))
                 yield return (FtpCommandHandlerExtension)Activator.CreateInstance(type.AsType(), connection);
         }
     }
 }
Exemplo n.º 4
0
 private void OnConfigureConnection(FtpConnection connection)
 {
     ConfigureConnection?.Invoke(this, new ConnectionEventArgs(connection));
 }
Exemplo n.º 5
0
        /// <summary>
        /// Enqueue a new <see cref="IBackgroundTransfer"/> for the given <paramref name="connection"/>
        /// </summary>
        /// <param name="backgroundTransfer">The background transfer to enqueue</param>
        /// <param name="connection">The connection to enqueue the background transfer for</param>
        public void EnqueueBackgroundTransfer([NotNull] IBackgroundTransfer backgroundTransfer, [CanBeNull] FtpConnection connection)
        {
            var entry = new BackgroundTransferEntry(backgroundTransfer, connection?.Log);

            BackgroundTransferWorker.Enqueue(entry);
        }
Exemplo n.º 6
0
 private void ConnectionReceived(object sender, TcpSocketListenerConnectEventArgs args)
 {
     var connection = new FtpConnection(this, args.SocketClient, DefaultEncoding);
     Statistics.ActiveConnections += 1;
     Statistics.TotalConnections += 1;
     connection.Closed += ConnectionOnClosed;
     _connections.Add(connection);
     connection.Log = LogManager?.CreateLog(connection);
     OnConfigureConnection(connection);
     connection.Start();
 }
Exemplo n.º 7
0
 private void OnConfigureConnection(FtpConnection connection)
 {
     if (ConfigureConnection != null)
         ConfigureConnection(this, new ConnectionEventArgs(connection));
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ConnectionEventArgs"/> class.
 /// </summary>
 /// <param name="connection">The connection of the event</param>
 public ConnectionEventArgs([NotNull] FtpConnection connection)
 {
     Connection = connection;
 }
Exemplo n.º 9
0
 /// <inheritdoc/>
 public IEnumerable <FtpCommandHandlerExtension> CreateCommandHandlerExtensions(FtpConnection connection)
 {
     return
         (from asm in _assemblies
          from type in asm.DefinedTypes
          where
          !type.IsAbstract &&
          type.IsSubclassOf(typeof(FtpCommandHandlerExtension)) &&
          type.AsType() != typeof(GenericFtpCommandHandlerExtension)
          select(FtpCommandHandlerExtension) Activator.CreateInstance(type.AsType(), connection));
 }
Exemplo n.º 10
0
 public IFtpLog CreateLog(FtpConnection connection)
 {
     return new FtpLogForNLog(connection);
 }
Exemplo n.º 11
0
 internal BackgroundCommandHandler(FtpConnection connection)
 {
     _connection = connection;
     _cancellationTokenRegistration = _connection.CancellationToken.Register(() => _cancellationTokenSource.Cancel(true));
 }
Exemplo n.º 12
0
 /// <inheritdoc/>
 public string BuildInfo(FtpConnection connection)
 {
     if (_toString == null)
         return _name;
     return _toString(connection);
 }
Exemplo n.º 13
0
 private void OnConfigureConnection(FtpConnection connection)
 {
     ConfigureConnection?.Invoke(this, new ConnectionEventArgs(connection));
 }
 internal BackgroundCommandHandler(FtpConnection connection)
 {
     _connection = connection;
     _cancellationTokenRegistration = _connection.CancellationToken.Register(() => _cancellationTokenSource.Cancel(true));
 }