예제 #1
0
        private void SetupFilesystem()
        {
            Debug.WriteLine("SetupFilesystem");

            var info = ConnectionType == ConnectionType.Password
                                      ? (ConnectionInfo) new PasswordConnectionInfo(Host, Port, Username, Password)
                                      : new PrivateKeyConnectionInfo(Host, Port, Username, new PrivateKeyFile(PrivateKey, Passphrase));

            _connection = String.Format("\\\\{0}\\{1}\\{2}", info.Host, Root, info.Username);
            _filesystem = new SftpFilesystem(info, Root, _connection);
            Debug.WriteLine("Connecting...");
            _filesystem.Connect();
        }
예제 #2
0
        private void SetupFilesystem()
        {
            Debug.WriteLine("SetupFilesystem");

            var info = ConnectionType == ConnectionType.Password
                                      ? (ConnectionInfo) new PasswordConnectionInfo(Host, Port, Username, Password)
                                      : new PrivateKeyConnectionInfo(Host, Port, Username, new PrivateKeyFile(PrivateKey, Passphrase));

            _connection = Settings.Default.UseNetworkDrive ? String.Format("\\\\{0}\\{1}\\{2}", info.Host, Root, info.Username) : Name;

            _filesystem = new SftpFilesystem(info, Root,_connection,Settings.Default.UseOfflineAttribute,false, (int) Settings.Default.AttributeCacheTimeout,  (int) Settings.Default.DirContentCacheTimeout);
            Debug.WriteLine("Connecting...");
            _filesystem.Connect();
        }
예제 #3
0
        private void SetupFilesystem()
        {
            Debug.WriteLine("SetupFilesystem");

            var info = ConnectionType == ConnectionType.Password
                                      ? (ConnectionInfo) new PasswordConnectionInfo(Host, Port, Username, Password)
                                      : new PrivateKeyConnectionInfo(Host, Port, Username, new PrivateKeyFile(PrivateKey, Passphrase));

            _connection = String.Format("\\\\{0}\\{1}\\{2}", info.Host, Root, info.Username);
            _filesystem = new SftpFilesystem(info, Root,_connection);
            Debug.WriteLine("Connecting...");
            _filesystem.Connect();
        }
예제 #4
0
        private void SetupFilesystem()
        {
            Debug.WriteLine("SetupFilesystem {0},{1},{2},{3}", Host, Port, Username, ConnectionType.ToString());

            ProxyTypes pt = ProxyTypes.None;

            switch (ProxyType)
            {
            case 1: pt = ProxyTypes.Http; break;

            case 2: pt = ProxyTypes.Socks4; break;

            case 3: pt = ProxyTypes.Socks5; break;
            }
            int ProxyPort = 8080;
            var Proxy     = ProxyHost;

            if (ProxyHost != null)
            {
                var s = ProxyHost.Split(':');
                if (s.Length > 1)
                {
                    Int32.TryParse(s[1], out ProxyPort);
                    Proxy = s[0];
                }
            }

            ConnectionInfo info;

            switch (ConnectionType)
            {
            case ConnectionType.Pageant:
                var agent = new PageantProtocol();
                if (pt == ProxyTypes.None)
                {
                    info = new AgentConnectionInfo(Host, Port, Username, agent);
                }
                else if (ProxyUser.Length > 0)
                {
                    info = new AgentConnectionInfo(Host, Port, Username, pt, Proxy, ProxyPort, ProxyUser, ProxyPass, agent);
                }
                else
                {
                    info = new AgentConnectionInfo(Host, Port, Username, pt, Proxy, ProxyPort, agent);
                }
                break;

            case ConnectionType.PrivateKey:
                if (pt == ProxyTypes.None)
                {
                    info = new PrivateKeyConnectionInfo(Host, Port, Username, new PrivateKeyFile(PrivateKey, Passphrase));
                }
                else if (ProxyUser.Length > 0)
                {
                    info = new PrivateKeyConnectionInfo(Host, Port, Username, pt, Proxy, ProxyPort, ProxyUser, ProxyPass, new PrivateKeyFile(PrivateKey, Passphrase));
                }
                else
                {
                    info = new PrivateKeyConnectionInfo(Host, Port, Username, pt, Proxy, ProxyPort, new PrivateKeyFile(PrivateKey, Passphrase));
                }
                break;

            default:
                if (pt == ProxyTypes.None)
                {
                    info = new PasswordConnectionInfo(Host, Port, Username, Password);
                }
                else if (ProxyUser.Length > 0)
                {
                    info = new PasswordConnectionInfo(Host, Username, Password, pt, Proxy, ProxyPort, ProxyUser, ProxyPass);
                }
                else
                {
                    info = new PasswordConnectionInfo(Host, Port, Username, Password, pt, Proxy, ProxyPort);
                }
                break;
            }

            _connection = Settings.Default.UseNetworkDrive ? String.Format("\\\\{0}\\{1}\\{2}", info.Host, Root, info.Username) : Name;

            _filesystem = new SftpFilesystem(info, Root, _connection, Settings.Default.UseOfflineAttribute, false, (int)Settings.Default.AttributeCacheTimeout, (int)Settings.Default.DirContentCacheTimeout);
            Debug.WriteLine("Connecting...");
            _filesystem.KeepAliveInterval = new TimeSpan(0, 0, 60);
            _filesystem.Connect();
        }
예제 #5
0
        private void SetupFilesystem()
        {
            Debug.WriteLine("SetupFilesystem {0},{1},{2},{3}",Host,Port,Username,ConnectionType.ToString());

            ProxyTypes pt = ProxyTypes.None;
            switch (ProxyType) {
              case 1: pt = ProxyTypes.Http; break;
              case 2: pt = ProxyTypes.Socks4; break;
              case 3: pt = ProxyTypes.Socks5; break;
            }
            int ProxyPort = 8080;
            var Proxy = ProxyHost;
            if (ProxyHost != null)
            {
                var s = ProxyHost.Split(':');
                if (s.Length > 1)
                {
                    Int32.TryParse(s[1], out ProxyPort);
                    Proxy = s[0];
                }
            }

            ConnectionInfo info;
            switch (ConnectionType)
            {
                case ConnectionType.Pageant:
                    var agent = new PageantProtocol();
                    if (pt == ProxyTypes.None) {
                      info = new AgentConnectionInfo(Host, Port, Username, agent);
                    }
                    else if (ProxyUser.Length>0) {
                      info = new AgentConnectionInfo(Host, Port, Username, pt, Proxy, ProxyPort, ProxyUser, ProxyPass, agent);
                    }
                    else {
                      info = new AgentConnectionInfo(Host, Port, Username, pt, Proxy, ProxyPort, agent);
                    }
                    break;
                case ConnectionType.PrivateKey:
                    if (pt == ProxyTypes.None) {
                      info = new PrivateKeyConnectionInfo(Host, Port, Username, new PrivateKeyFile(PrivateKey, Passphrase));
                    }
                    else if (ProxyUser.Length > 0) {
                      info = new PrivateKeyConnectionInfo(Host, Port, Username, pt, Proxy, ProxyPort, ProxyUser, ProxyPass, new PrivateKeyFile(PrivateKey, Passphrase));
                    }
                    else {
                      info = new PrivateKeyConnectionInfo(Host, Port, Username, pt, Proxy, ProxyPort, new PrivateKeyFile(PrivateKey, Passphrase));
                    }
                    break;
                default:
                    if (pt == ProxyTypes.None) {
                      info = new PasswordConnectionInfo(Host, Port, Username, Password);
                    }
                    else if (ProxyUser.Length > 0) {
                      info = new PasswordConnectionInfo(Host, Username, Password, pt, Proxy, ProxyPort, ProxyUser, ProxyPass);
                    }
                    else {
                      info = new PasswordConnectionInfo(Host, Port, Username, Password, pt, Proxy, ProxyPort);
                    }
                    break;
            }

            _connection = Settings.Default.UseNetworkDrive ? String.Format("\\\\{0}\\{1}\\{2}", info.Host, Root, info.Username) : Name;

            _filesystem = new SftpFilesystem(info, Root,_connection,Settings.Default.UseOfflineAttribute,false, (int) Settings.Default.AttributeCacheTimeout,  (int) Settings.Default.DirContentCacheTimeout);
            Debug.WriteLine("Connecting...");
            _filesystem.KeepAliveInterval = new TimeSpan(0, 0, 60);
            _filesystem.Connect();
        }