Beispiel #1
0
        /// <summary>
        /// Checks the protection.
        /// </summary>
        /// <param name="requiredChannelProtection">The required channel protection.</param>
        public void CheckProtection(FtpProtection requiredChannelProtection)
        {
            // for FTP, don't even bother
            if (Connection.Client.Protocol == FtpProtocol.Ftp)
            {
                return;
            }
            var prot = Connection.Client.ChannelProtection.HasFlag(requiredChannelProtection) ? "P" : "C";

            State["PROT"] = prot;
        }
Beispiel #2
0
 public FtpClientParameters(bool passive, FtpProtection channelProtection = FtpProtection.Ftp,
                            SslType sslType = SslType.Default)
 {
     // Inicializa las propiedades
     Passive           = passive;
     ChannelProtection = channelProtection;
     SslProtocol       = sslType;
     // Lanza una excepción si no cumple con los parámetros
     if (!Passive && ProxyConnect != null)
     {
         throw new InvalidOperationException("El modo de transferencia activo sólo funciona sin servidor proxy");
     }
 }
Beispiel #3
0
        /// <summary>
        /// Checks the protection.
        /// </summary>
        /// <param name="requiredChannelProtection">The required channel protection.</param>
        /// <param name="bufferSize">Size of the buffer.</param>
        public void CheckProtection(FtpProtection requiredChannelProtection, int?bufferSize = null)
        {
            // for FTP, don't even bother
            if (Connection.Client.Protocol == FtpProtocol.Ftp)
            {
                return;
            }
            var prot = Connection.Client.ChannelProtection.HasFlag(requiredChannelProtection) ? "P" : "C";

            if (bufferSize.HasValue)
            {
                State["PBSZ"] = bufferSize.Value.ToString(CultureInfo.InvariantCulture);
            }
            State["PROT"] = prot;
        }
Beispiel #4
0
 private static void ListTest(bool passive, string hostType = null, FtpProtection? protection = null, string protocol = "ftp")
 {
     var ftpTestHost = GetTestHost(protocol, hostType);
     using (var ftpClient = new FtpClient(ftpTestHost.Uri, ftpTestHost.Credential, new FtpClientParameters { Passive = passive, ChannelProtection = protection }))
     {
         var list = ftpClient.ListEntries("/");
         if (ftpClient.ServerType == FtpServerType.Unix)
             Assert.IsTrue(list.Any(e => e.Name == "tmp"));
     }
 }