public async Task <Stream> OpenDataStreamAsync(string host, int port, CancellationToken token)
        {
            Logger?.LogDebug("[FtpSocketStream] Opening datastream");
            var socketStream = new FTPControlStream(Configuration, dnsResolver)
            {
                Logger = Logger, IsDataConnection = true
            };
            await socketStream.ConnectStreamAsync(host, port, token);

            if (IsEncrypted)
            {
                await socketStream.ActivateEncryptionAsync();
            }
            return(socketStream);
        }
Exemple #2
0
        public void Configure(FTPClientConfiguration configuration)
        {
            Configuration = configuration;

            if (configuration.Host == null)
            {
                throw new ArgumentNullException(nameof(configuration.Host));
            }

            if (Uri.IsWellFormedUriString(configuration.Host, UriKind.Absolute))
            {
                configuration.Host = new Uri(configuration.Host).Host;
            }


            ControlStream = new FTPControlStream(Configuration, new DnsResolver());
            Configuration.BaseDirectory = $"/{Configuration.BaseDirectory.TrimStart('/')}";
        }