/// <summary> /// Stops the running FTP server. /// </summary> /// <param name="cancellationToken"></param> /// <returns></returns> async Task StopFtpServer(CancellationToken cancellationToken) { if (ftpServer != null) { try { await Task.Run(() => ftpServer.Stop()); } catch (Exception) { try { if (ftpServer != null) { ftpServer.Stop(); } } catch (Exception) { // gave it our best go. } } finally { ftpServer = null; } } }
/// <summary> /// Initializes a new instance of the <see cref="StatCommandHandler"/> class. /// </summary> /// <param name="server">The FTP server.</param> /// <param name="backgroundTransferWorker">The background transfer worker service.</param> public StatCommandHandler( [NotNull] IFtpServer server, [NotNull] IBackgroundTransferWorker backgroundTransferWorker) { _server = server; _backgroundTransferWorker = backgroundTransferWorker; }
private void CopyEntity(IFtpServer source, IFtpServer dest) { dest.Host = source.Host; dest.Name = source.Name; dest.Password = source.Password; dest.Port = source.Port; dest.User = source.User; }
/// <summary> /// Initializes a new instance of the <see cref="FtpServerHostApi"/> class. /// </summary> /// <param name="applicationLifetime">The application lifetime.</param> /// <param name="ftpServer">The FTP server to control/query.</param> /// <param name="moduleInfoItems">The registered information modules.</param> public FtpServerHostApi( IApplicationLifetime applicationLifetime, IFtpServer ftpServer, IEnumerable <IModuleInfo> moduleInfoItems) { _applicationLifetime = applicationLifetime; _ftpServer = ftpServer; _moduleInfoItems = moduleInfoItems.ToList(); }
/// <summary> /// Initializes a new instance of the <see cref="StatCommandHandler"/> class. /// </summary> /// <param name="connectionAccessor">The accessor to get the connection that is active during the <see cref="Process"/> method execution.</param> /// <param name="server">The FTP server.</param> /// <param name="backgroundTransferWorker">The background transfer worker service.</param> public StatCommandHandler( [NotNull] IFtpConnectionAccessor connectionAccessor, [NotNull] IFtpServer server, [NotNull] IBackgroundTransferWorker backgroundTransferWorker) : base(connectionAccessor, "STAT") { _server = server; _backgroundTransferWorker = backgroundTransferWorker; }
public void Add(IFtpServer ftpServer) { var copy = new FtpServer(); CopyEntity(copy, ftpServer); copy.Id = _lastId++; _servers.Add(copy); }
public FtpServerViewModel( IResolve dependencyService, IFtpServer ftpServer) { DependencyService = dependencyService; FtpServer = ftpServer; ConnectToServerCommand = new RelayCommand(InitialConnectToServer); MessengerInstance.Register <ChangeWorkingDirectoryMessage>(this, SetWorkingDirectory); }
/// <summary> /// Stops the running FTP server. /// </summary> /// <param name="cancellationToken"></param> /// <returns></returns> async Task StopFtpServer(CancellationToken cancellationToken) { if (_ftpServer is IFtpServer) { try { await _ftpServer.StopAsync(cancellationToken); } catch (Exception) { _ftpServer = null; } } }
/// <summary> /// Starts the FTP server. Returns the address the service is listening on. /// </summary> /// <param name="cancellationToken"></param> /// <returns></returns> async Task <string> StartFtpServer(CancellationToken cancellationToken) { var endpoint = _serviceContext.CodePackageActivationContext.GetEndpoint(_endpointName); if (endpoint == null || endpoint.Protocol != EndpointProtocol.Tcp) { throw new InvalidOperationException($"Unable to find TCP endpoint named '{_endpointName}'."); } var host = _serviceContext.NodeContext.IPAddressOrFQDN; var port = endpoint.Port; _ftpServer = _build(host, port); if (_ftpServer == null) { throw new InvalidOperationException("Unable to build FtpServer instance."); } try { // queues the FTP server to start await _ftpServer.StartAsync(cancellationToken); // ftp server starts in background, wait for completion while (!_ftpServer.Ready && !cancellationToken.IsCancellationRequested) { await Task.Delay(TimeSpan.FromSeconds(1), cancellationToken); } // yield out address server ended up listening on return(new Uri($"ftp://{host}:{port}/").ToString()); } catch (Exception) { await StopFtpServer(cancellationToken); throw; } }
/// <summary> /// Initializes a new instance of the <see cref="StatCommandHandler"/> class. /// </summary> /// <param name="connection">The connection to create this command handler for.</param> /// <param name="server">The FTP server.</param> public StatCommandHandler([NotNull] IFtpConnection connection, [NotNull] IFtpServer server) : base(connection, "STAT") { _server = server; }
/// <summary> /// Initializes a new instance of the <see cref="FtpServerInfo"/>. /// </summary> /// <param name="ftpServer">The FTP server to get the information from.</param> public FtpServerInfo([NotNull] IFtpServer ftpServer) { _ftpServer = ftpServer; }
public IntegrationTests(FtpServerFixture ftpServerFixture) { _server = ftpServerFixture.Server; _client = new FtpClient("127.0.0.1", _server.Port, "anonymous", "*****@*****.**"); }
/// <summary> /// Initializes a new instance of the <see cref="PasvCommandHandler"/> class. /// </summary> /// <param name="connection">The connection this command handler is created for.</param> /// <param name="ftpServer"></param> public PasvCommandHandler([NotNull] IFtpConnection connection, IFtpServer ftpServer) : base(connection, "PASV", "EPSV") { _ftpServer = ftpServer; }
public FtpServerViewModel(IFtpServer ftpServer) { _ftpServer = ftpServer; }
/// <summary> /// Initializes a new instance of the <see cref="FtpServerInfo"/>. /// </summary> /// <param name="ftpServer">The FTP server to get the information from.</param> public FtpServerInfo(IFtpServer ftpServer) { _ftpServer = ftpServer; }
public void Update(IFtpServer ftpServer) { var val = _servers.First(x => x.Id == ftpServer.Id); CopyEntity(val, ftpServer); }
public Issue30CustomFtpUser(Issue30FtpServerFixture ftpServerFixture) { _server = ftpServerFixture.Server; }
/// <summary> /// Initializes a new instance of the <see cref="AppeCommandHandler"/> class. /// </summary> /// <param name="connection">The connection to create this command handler for.</param> /// <param name="server">The FTP server.</param> public AppeCommandHandler([NotNull] IFtpConnection connection, [NotNull] IFtpServer server) : base(connection, "APPE") { _server = server; }
public Issue82ProtocolViolation(FtpServerFixture ftpServerFixture) { _server = ftpServerFixture.Server; }
/// <summary> /// Initializes a new instance of the <see cref="SiteBlstCommandExtension"/> class. /// </summary> /// <param name="connection">The connection this instance is used for.</param> /// <param name="server">The FTP server.</param> /// <param name="logger">The logger.</param> public SiteBlstCommandExtension([NotNull] IFtpConnection connection, [NotNull] IFtpServer server, [CanBeNull] ILogger <SiteBlstCommandExtension> logger = null) : base(connection, "SITE", "BLST") { _server = server; _logger = logger; }