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); } } }
private void OnConfigureConnection(FtpConnection connection) { ConfigureConnection?.Invoke(this, new ConnectionEventArgs(connection)); }
/// <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); }
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(); }
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; }
/// <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)); }
public IFtpLog CreateLog(FtpConnection connection) { return new FtpLogForNLog(connection); }
internal BackgroundCommandHandler(FtpConnection connection) { _connection = connection; _cancellationTokenRegistration = _connection.CancellationToken.Register(() => _cancellationTokenSource.Cancel(true)); }
/// <inheritdoc/> public string BuildInfo(FtpConnection connection) { if (_toString == null) return _name; return _toString(connection); }