This class represents a FTP connection
Наследование: IDisposable
Пример #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);
         }
     }
 }
Пример #4
0
 private void OnConfigureConnection(FtpConnection connection)
 {
     ConfigureConnection?.Invoke(this, new ConnectionEventArgs(connection));
 }
Пример #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);
        }
Пример #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();
 }
Пример #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;
 }
Пример #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));
 }
Пример #10
0
 public IFtpLog CreateLog(FtpConnection connection)
 {
     return new FtpLogForNLog(connection);
 }
Пример #11
0
 internal BackgroundCommandHandler(FtpConnection connection)
 {
     _connection = connection;
     _cancellationTokenRegistration = _connection.CancellationToken.Register(() => _cancellationTokenSource.Cancel(true));
 }
Пример #12
0
 /// <inheritdoc/>
 public string BuildInfo(FtpConnection connection)
 {
     if (_toString == null)
         return _name;
     return _toString(connection);
 }
Пример #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));
 }