예제 #1
0
        public void SuccessfullyExit(ITerminalConnection connection)
        {
            ITerminalSettings terminalSettings = PoderosaTerminalEmulatorService.CreateDefaultTerminalSettings(Connection.DisplayName, null);

            TerminalSession session       = new TerminalSession(connection, terminalSettings);
            SessionHost     sessionHost   = new SessionHost(PoderosaSessionManagerPlugin, session);
            TerminalView    terminalView  = new TerminalView(null, _terminal);
            RenderProfile   renderProfile = new RenderProfile(_terminal.GetRenderProfile());

            renderProfile.BackColor = Connection.BackgroundColor;
            renderProfile.ForeColor = Connection.TextColor;

            session.TerminalSettings.BeginUpdate();
            session.TerminalSettings.RenderProfile = renderProfile;
            session.TerminalSettings.EndUpdate();

            _sshConnection = (SSHTerminalConnection)connection;

            Invoke(
                new Action(
                    () =>
            {
                _terminal.Attach(session);

                session.InternalStart(sessionHost);
                session.InternalAttachView(sessionHost.DocumentAt(0), terminalView);

                _sshConnection.ConnectionEventReceiver.NormalTermination   += ConnectionEventReceiver_NormalTermination;
                _sshConnection.ConnectionEventReceiver.AbnormalTermination += ConnectionEventReceiver_AbnormalTermination;

                ParentForm.Closing += ParentForm_OnClosing;

                OnConnected(_terminal, null);
            }));
        }
예제 #2
0
        protected override void Negotiate()
        {
            SSHConnectionParameter con = new SSHConnectionParameter();

            con.Protocol           = _param.Method == ConnectionMethod.SSH1 ? SSHProtocol.SSH1 : SSHProtocol.SSH2;
            con.CheckMACError      = GEnv.Options.SSHCheckMAC;
            con.UserName           = _param.Account;
            con.Password           = _password;
            con.AuthenticationType = _param.AuthType == AuthType.KeyboardInteractive ? AuthenticationType.KeyboardInteractive : _param.AuthType == AuthType.Password ? AuthenticationType.Password : AuthenticationType.PublicKey;
            con.IdentityFile       = _param.IdentityFile;
            con.TerminalWidth      = _size.Width;
            con.TerminalHeight     = _size.Height;
            con.TerminalName       = EnumDescAttribute.For(typeof(TerminalType)).GetDescription(_param.TerminalType);
            //con.TerminalName = "xterm";
            con.WindowSize = GEnv.Options.SSHWindowSize;
            con.PreferableCipherAlgorithms  = LocalSSHUtil.ParseCipherAlgorithm(GEnv.Options.CipherAlgorithmOrder);
            con.PreferableHostKeyAlgorithms = LocalSSHUtil.ParsePublicKeyAlgorithm(GEnv.Options.HostKeyAlgorithmOrder);
            if (_keycheck != null)
            {
                con.KeyCheck += new HostKeyCheckCallback(this.CheckKey);
            }

            SSHTerminalConnection r   = new SSHTerminalConnection(_param, _size.Width, _size.Height);
            SSHConnection         ssh = SSHConnection.Connect(con, r, _socket);

            if (ssh != null)
            {
                if (GEnv.Options.RetainsPassphrase)
                {
                    _param.Passphrase = _password;
                }

                r.FixConnection(ssh);

                if (ssh.AuthenticationResult == AuthenticationResult.Success)
                {
                    r.OpenShell();
                }

                r.UsingSocks = _socks != null;
                r.SetServerInfo(_param.Host, this.IPAddress);

                _result = new ConnectionTag(r);
            }
            else
            {
                throw new IOException(GEnv.Strings.GetString("Message.SSHConnector.Cancelled"));
            }
        }