Esempio n. 1
0
        private void connect_Click(object sender, EventArgs e)
        {
            this.Hide();

            int p = 22;

            sshfs = new SSHFS();
            opt   = new DokanOptions();

            if (DokanSSHFS.DokanDebug)
            {
                opt |= DokanOptions.DebugMode;
            }
            opt        |= DokanOptions.AltStream; // DokanOptions.KeepAlive always enabled.
            mountPoint  = "n:\\";
            threadCount = 0;

            string message = "";

            if (host.Text == "")
            {
                message += "Host name is empty\n";
            }

            if (user.Text == "")
            {
                message += "User name is empty\n";
            }


            if (port.Text == "")
            {
                message += "Port is empty\n";
            }
            else
            {
                try
                {
                    p = Int32.Parse(port.Text);
                }
                catch (Exception)
                {
                    message += "Port format error\n";
                }
            }


            if (drive.Text.Length != 1)
            {
                message += "Drive letter is invalid\n";
            }
            else
            {
                char letter = drive.Text[0];
                letter = Char.ToLower(letter);
                if (!('e' <= letter && letter <= 'z'))
                {
                    message += "Drive letter is invalid\n";
                }

                mountPoint   = string.Format("{0}:\\", letter);
                unmount.Text = "Unmount (" + mountPoint + ")";
            }

            threadCount = DokanSSHFS.DokanThread;

            if (message.Length != 0)
            {
                this.Show();
                MessageBox.Show(message, "Error");
                return;
            }

            DokanSSHFS.UseOffline = !withoutOfflineAttribute.Checked;

            sshfs.Initialize(
                user.Text,
                host.Text,
                p,
                usePrivateKey.Checked ? null : password.Text,
                usePrivateKey.Checked ? privatekey.Text : null,
                usePrivateKey.Checked ? passphrase.Text : null,
                root.Text,
                DokanSSHFS.SSHDebug);

            if (sshfs.SSHConnect())
            {
                unmount.Visible = true;
                mount.Visible   = false;
                isUnmounted_    = false;

                MountWorker worker = null;
                if (disableCache.Checked)
                {
                    worker = new MountWorker(sshfs, opt, mountPoint, threadCount);
                }
                else
                {
                    worker = new MountWorker(new CacheOperations(sshfs), opt, mountPoint, threadCount);
                }

                dokan = new Thread(worker.Start);
                dokan.Start();
            }
            else
            {
                this.Show();
                MessageBox.Show("failed to connect", "Error");
                return;
            }

            MessageBox.Show("sshfs start", "info");
        }
Esempio n. 2
0
        private void connect()
        {
            int p = 22;

            sshfs = new SSHFS();
            opt = new DokanOptions();
            opt.DebugMode = parser.debug;
            opt.UseAltStream = true;
            opt.ThreadCount = 0;
            opt.UseKeepAlive = true;

            string message = "";

            if (parser.host == "")
                message += "Host name is empty\n";

            if (parser.user == "")
                message += "User name is empty\n";

            if (parser.drive.Length != 1)
            {
                message += "Drive letter is invalid\n";
            }
            else
            {
                char letter = parser.drive[0];
                letter = Char.ToLower(letter);
                if (!('e' <= letter && letter <= 'z'))
                    message += "Drive letter is invalid\n";

                opt.MountPoint = string.Format("{0}:\\", letter);
                unmount.Text = "Unmount (" + opt.MountPoint + ")";
            }

            opt.MountPoint = string.Format("{0}:\\", 'r');
            unmount.Text = "Unmount (" + opt.MountPoint + ")";
            opt.UseStdErr = parser.debug;

            opt.ThreadCount = DokanSSHFS.DokanThread;

            if (message.Length != 0)
            {
                MessageBox.Show(message, "Error");
                return;
            }

            //            DokanSSHFS.UseOffline = !withoutOfflineAttribute.Checked;
            DokanSSHFS.UseOffline = false;

            //TODO: Add password auth and key passphrase support
            sshfs.Initialize(
                parser.user,
                parser.host,
                p,
                null,
                parser.identity,
                "",
                parser.root,
                DokanSSHFS.SSHDebug);

            if (sshfs.SSHConnect())
            {
                unmount.Visible = true;
                mount.Visible = false;
                isUnmounted_ = false;

                MountWorker worker = null;
            //                if (disableCache.Checked)
            //                {
                    worker = new MountWorker(sshfs, opt);
            //                }
            //                else
            //                {
            //                    worker = new MountWorker(new CacheOperations(sshfs), opt);
            //                }

                dokan = new Thread(worker.Start);
                dokan.Start();
            }
            else
            {
                MessageBox.Show("failed to connect", "Error");
                return;
            }

            //            MessageBox.Show("sshfs start", "info");
        }
Esempio n. 3
0
        private void connect_Click(object sender, EventArgs e)
        {
            this.Hide();

            int p = 22;

            sshfs = new SSHFS();
            opt = new DokanOptions();

            opt.DebugMode = DokanSSHFS.DokanDebug;
            opt.UseAltStream = true;
            opt.MountPoint = "n:\\";
            opt.ThreadCount = 0;
            opt.UseKeepAlive = true;

            string message = "";

            if (host.Text == "")
                message += "Host name is empty\n";

            if (user.Text == "")
                message += "User name is empty\n";

            if (port.Text == "")
                message += "Port is empty\n";
            else
            {
                try
                {
                    p = Int32.Parse(port.Text);
                }
                catch(Exception)
                {
                    message += "Port format error\n";
                }
            }

            if (drive.Text.Length != 1)
            {
                message += "Drive letter is invalid\n";
            }
            else
            {
                char letter = drive.Text[0];
                letter = Char.ToLower(letter);
                if (!('e' <= letter && letter <= 'z'))
                    message += "Drive letter is invalid\n";

                opt.MountPoint = string.Format("{0}:\\", letter);
                unmount.Text = "Unmount (" + opt.MountPoint + ")";
            }

            opt.ThreadCount = DokanSSHFS.DokanThread;

            if (message.Length != 0)
            {
                this.Show();
                MessageBox.Show(message, "Error");
                return;
            }

            DokanSSHFS.UseOffline = !withoutOfflineAttribute.Checked;

            sshfs.Initialize(
                user.Text,
                host.Text,
                p,
                usePrivateKey.Checked ? null : password.Text,
                usePrivateKey.Checked ? privatekey.Text : null,
                usePrivateKey.Checked ? passphrase.Text : null,
                root.Text,
                DokanSSHFS.SSHDebug);

            if (sshfs.SSHConnect())
            {
                unmount.Visible = true;
                mount.Visible = false;
                isUnmounted_ = false;

                MountWorker worker = null;
                if (disableCache.Checked)
                {
                    worker = new MountWorker(sshfs, opt);
                }
                else
                {
                    worker = new MountWorker(new CacheOperations(sshfs), opt);
                }

                dokan = new Thread(worker.Start);
                dokan.Start();
            }
            else
            {
                this.Show();
                MessageBox.Show("failed to connect", "Error");
                return;
            }

            MessageBox.Show("sshfs start", "info");
        }
Esempio n. 4
0
        private void connect()
        {
            int p = 22;

            sshfs            = new SSHFS();
            opt              = new DokanOptions();
            opt.DebugMode    = parser.debug;
            opt.UseAltStream = true;
            opt.ThreadCount  = 0;
            opt.UseKeepAlive = true;

            string message = "";

            if (parser.host == "")
            {
                message += "Host name is empty\n";
            }

            if (parser.user == "")
            {
                message += "User name is empty\n";
            }

            if (parser.drive.Length != 1)
            {
                message += "Drive letter is invalid\n";
            }
            else
            {
                char letter = parser.drive[0];
                letter = Char.ToLower(letter);
                if (!('e' <= letter && letter <= 'z'))
                {
                    message += "Drive letter is invalid\n";
                }

                opt.MountPoint = string.Format("{0}:\\", letter);
                unmount.Text   = "Unmount (" + opt.MountPoint + ")";
            }

            opt.MountPoint = string.Format("{0}:\\", 'r');
            unmount.Text   = "Unmount (" + opt.MountPoint + ")";
            opt.UseStdErr  = parser.debug;

            opt.ThreadCount = DokanSSHFS.DokanThread;

            if (message.Length != 0)
            {
                MessageBox.Show(message, "Error");
                return;
            }

//            DokanSSHFS.UseOffline = !withoutOfflineAttribute.Checked;
            DokanSSHFS.UseOffline = false;

            //TODO: Add password auth and key passphrase support
            sshfs.Initialize(
                parser.user,
                parser.host,
                p,
                null,
                parser.identity,
                "",
                parser.root,
                DokanSSHFS.SSHDebug);

            if (sshfs.SSHConnect())
            {
                unmount.Visible = true;
                mount.Visible   = false;
                isUnmounted_    = false;

                MountWorker worker = null;
//                if (disableCache.Checked)
//                {
                worker = new MountWorker(sshfs, opt);
//                }
//                else
//                {
//                    worker = new MountWorker(new CacheOperations(sshfs), opt);
//                }

                dokan = new Thread(worker.Start);
                dokan.Start();
            }
            else
            {
                MessageBox.Show("failed to connect", "Error");
                return;
            }

//            MessageBox.Show("sshfs start", "info");
        }