Example #1
0
        private bool CommitSSHOptions()
        {
            //暗号アルゴリズム順序は_optionsを直接いじっているのでここでは何もしなくてよい
            try {
                PublicKeyAlgorithm[] pa = new PublicKeyAlgorithm[2];
                if (_hostKeyBox.SelectedIndex == 0)
                {
                    pa[0] = PublicKeyAlgorithm.DSA;
                    pa[1] = PublicKeyAlgorithm.RSA;
                }
                else
                {
                    pa[0] = PublicKeyAlgorithm.RSA;
                    pa[1] = PublicKeyAlgorithm.DSA;
                }
                _options.HostKeyAlgorithmOrder = SSHUtil.FormatPublicKeyAlgorithmList(pa);

                try {
                    _options.SSHWindowSize = Int32.Parse(_windowSizeBox.Text);
                }
                catch (FormatException) {
                    Util.Warning(this, Env.Strings.GetString("Message.OptionDialog.InvalidWindowSize"));
                    return(false);
                }

                _options.RetainsPassphrase = _retainsPassphrase.Checked;
                _options.SSHCheckMAC       = _sshCheckMAC.Checked;

                return(true);
            }
            catch (Exception ex) {
                Util.Warning(this, ex.Message);
                return(false);
            }
        }
Example #2
0
        private void OptionDialog_Load(object sender, System.EventArgs args)
        {
            _options = (Options)Env.Options.Clone();

            //SSH
            string[] co = _options.CipherAlgorithmOrder;
            foreach (string c in co)
            {
                _cipherOrderList.Items.Add(c);
            }
            _hostKeyBox.SelectedIndex  = SSHUtil.ParsePublicKeyAlgorithm(_options.HostKeyAlgorithmOrder[0]) == PublicKeyAlgorithm.DSA ? 0 : 1; //これはDSA/RSAのどちらかしかない
            _windowSizeBox.Text        = _options.SSHWindowSize.ToString();
            _retainsPassphrase.Checked = _options.RetainsPassphrase;
            _sshCheckMAC.Checked       = _options.SSHCheckMAC;

            //接続
            _useSocks.Checked        = _options.UseSocks;
            _socksServerBox.Text     = _options.SocksServer;
            _socksPortBox.Text       = _options.SocksPort.ToString();
            _socksAccountBox.Text    = _options.SocksAccount;
            _socksPasswordBox.Text   = _options.SocksPassword;
            _socksNANetworksBox.Text = _options.SocksNANetworks;

            //一般
            _showInTaskBarOption.Checked      = _options.ShowInTaskBar;
            _warningOnExit.Checked            = _options.WarningOnExit;
            _optionPreservePlace.SelectedItem = _options.OptionPreservePlace; // select EnumListItem<T> by T
            _languageBox.SelectedItem         = _options.Language;            // select EnumListItem<T> by T
        }
Example #3
0
        protected override void Negotiate()
        {
            SSHConnectionParameter con = new SSHConnectionParameter();

            con.Protocol                    = SSHProtocol.SSH2;
            con.UserName                    = _profile.SSHAccount;
            con.Password                    = _password;
            con.AuthenticationType          = _profile.AuthType;
            con.IdentityFile                = _profile.PrivateKeyFile;
            con.PreferableCipherAlgorithms  = SSHUtil.ParseCipherAlgorithm(Env.Options.CipherAlgorithmOrder);
            con.PreferableHostKeyAlgorithms = SSHUtil.ParsePublicKeyAlgorithm(Env.Options.HostKeyAlgorithmOrder);
            con.WindowSize                  = Env.Options.SSHWindowSize;
            con.CheckMACError               = Env.Options.SSHCheckMAC;
            if (_keycheck != null)
            {
                con.KeyCheck += new HostKeyCheckCallback(this.CheckKey);
            }

            _result = ChannelFactory.Create(_profile);
            SSHConnection c = SSHConnection.Connect(con, _result, _socket);

            c.AutoDisconnect = false;
            if (c != null)
            {
                /*
                 * if(_profile.ProtocolType==ProtocolType.Udp)
                 *  OpenUdpDestination(c, (UdpChannelFactory)_result);
                 * else
                 */
                _result.FixConnection(c);
                if (Env.Options.RetainsPassphrase)
                {
                    _profile.Passphrase = _password; //接続成功時のみセット
                }
            }
            else
            {
                throw new IOException(Env.Strings.GetString("Message.ConnectionManager.ConnectionCancelled"));
            }
        }
Example #4
0
        protected override void Negotiate()
        {
            SSHConnectionParameter con = new SSHConnectionParameter(_host, _port, SSHProtocol.SSH2, _profile.AuthType, _profile.SSHAccount, _password);

            con.IdentityFile = _profile.PrivateKeyFile;
            con.PreferableCipherAlgorithms  = SSHUtil.ParseCipherAlgorithm(Env.Options.CipherAlgorithmOrder);
            con.PreferableHostKeyAlgorithms = SSHUtil.ParsePublicKeyAlgorithm(Env.Options.HostKeyAlgorithmOrder);
            con.WindowSize    = Env.Options.SSHWindowSize;
            con.CheckMACError = Env.Options.SSHCheckMAC;
            if (_keycheck != null)
            {
                con.VerifySSHHostKey = this.CheckKey;
            }

            _result = ChannelFactory.Create(_profile);
            ISSHConnection c = SSHConnection.Connect(
                _socket, con,
                sshconn => _result, null);

            if (c != null)
            {
                /*
                 * if(_profile.ProtocolType==ProtocolType.Udp)
                 *  OpenUdpDestination(c, (UdpChannelFactory)_result);
                 * else
                 */
                _result.FixConnection(c);
                if (Env.Options.RetainsPassphrase)
                {
                    _profile.Passphrase = _password; //接続成功時のみセット
                }
            }
            else
            {
                throw new IOException(Env.Strings.GetString("Message.ConnectionManager.ConnectionCancelled"));
            }
        }