示例#1
0
        public SessionDataStartInfo ToSessionStartInfo()
        {
            SessionDataStartInfo ssi = null;

            if (this.SessionId != null)
            {
                // first try to resolve by sessionId
                SessionData session = SuperPuTTY.GetSessionById(this.SessionId);
                if (session == null)
                {
                    Log.WarnFormat("Session from command line not found, id={0}", this.SessionId);
                }
                else
                {
                    ssi = new SessionDataStartInfo
                    {
                        Session = session,
                        UseScp  = this.UseScp
                    };
                }
            }
            else if (this.Host != null || this.PuttySession != null)
            {
                // Host or puttySession provided
                string sessionName;
                if (this.Host != null)
                {
                    // Decode URL type host spec, if provided (e.g. ssh://localhost:2020)
                    HostConnectionString connStr = new HostConnectionString(this.Host);
                    this.Host     = connStr.Host;
                    this.Protocol = connStr.Protocol.GetValueOrDefault(this.Protocol.GetValueOrDefault(ConnectionProtocol.SSH));
                    this.Port     = connStr.Port.GetValueOrDefault(this.Port.GetValueOrDefault(dlgEditSession.GetDefaultPort(this.Protocol.GetValueOrDefault())));
                    sessionName   = this.Host;
                }
                else
                {
                    // no host provided so assume sss
                    sessionName = this.PuttySession;
                }

                ssi = new SessionDataStartInfo
                {
                    Session = new SessionData
                    {
                        Host         = this.Host,
                        SessionName  = sessionName,
                        SessionId    = SuperPuTTY.MakeUniqueSessionId(SessionData.CombineSessionIds("CLI", this.Host)),
                        Port         = this.Port.GetValueOrDefault(22),
                        Proto        = this.Protocol.GetValueOrDefault(ConnectionProtocol.SSH),
                        Username     = this.UserName,
                        Password     = this.Password,
                        PuttySession = this.PuttySession
                    },
                    UseScp = this.UseScp
                };
            }

            if (ssi == null)
            {
                Log.WarnFormat("Could not determine session or host to connect.  SessionId or Host or PuttySession must be provided");
            }

            return(ssi);
        }
示例#2
0
        void TryConnectFromToolbar()
        {
            String host = this.tbTxtBoxHost.Text;
            String protoString = (string)this.tbComboProtocol.SelectedItem;

            if (!String.IsNullOrEmpty(host))
            {
                HostConnectionString connStr = new HostConnectionString(host);
                bool isScp = "SCP" == protoString;
                ConnectionProtocol proto = isScp
                    ? ConnectionProtocol.SSH
                    : connStr.Protocol.GetValueOrDefault((ConnectionProtocol)Enum.Parse(typeof(ConnectionProtocol), protoString));
                SessionData session = new SessionData
                {
                    Host = connStr.Host,
                    SessionName = connStr.Host,
                    SessionId = SuperPuTTY.MakeUniqueSessionId(SessionData.CombineSessionIds("ConnectBar", connStr.Host)),
                    Proto = proto,
                    Port = connStr.Port.GetValueOrDefault(dlgEditSession.GetDefaultPort(proto)),
                    Username = this.tbTxtBoxLogin.Text,
                    Password = this.tbTxtBoxPassword.Text,
                    PuttySession = (string)this.tbComboSession.SelectedItem
                };
                SuperPuTTY.OpenSession(new SessionDataStartInfo { Session = session, UseScp = isScp });
                oldHostName = this.tbTxtBoxHost.Text;
                RefreshConnectionToolbarData();
            }
        }
示例#3
0
        public SessionDataStartInfo ToSessionStartInfo()
        {
            SessionDataStartInfo ssi = null;
            if (this.SessionId != null)
            {
                // first try to resolve by sessionId
                SessionData session = SuperPuTTY.GetSessionById(this.SessionId);
                if (session == null)
                {
                    Log.WarnFormat("Session from command line not found, id={0}", this.SessionId);
                }
                else
                {
                    ssi = new SessionDataStartInfo 
                    { 
                        Session = session, 
                        UseScp = this.UseScp 
                    };
                }
            }
            else if (this.Host != null ||  this.PuttySession != null)
            {
                // Host or puttySession provided
                string sessionName;
                if (this.Host != null)
                {
                    // Decode URL type host spec, if provided (e.g. ssh://localhost:2020)
                    HostConnectionString connStr = new HostConnectionString(this.Host);
                    this.Host = connStr.Host;
                    this.Protocol = connStr.Protocol.GetValueOrDefault(this.Protocol.GetValueOrDefault(ConnectionProtocol.SSH));
                    this.Port = connStr.Port.GetValueOrDefault(this.Port.GetValueOrDefault(dlgEditSession.GetDefaultPort(this.Protocol.GetValueOrDefault())));
                    sessionName = this.Host;
                }
                else
                {
                    // no host provided so assume sss
                    sessionName = this.PuttySession;
                }

                ssi = new SessionDataStartInfo();
                ssi.Session = new SessionData
                {
                    Host = this.Host,
                    SessionName = sessionName,
                    SessionId = SuperPuTTY.MakeUniqueSessionId(SessionData.CombineSessionIds("CLI", this.Host)),
                    Port = this.Port.GetValueOrDefault(22),
                    Proto = this.Protocol.GetValueOrDefault(ConnectionProtocol.SSH),
                    Username = this.UserName,
                    Password = this.Password,
                    PuttySession = this.PuttySession
                };
                ssi.UseScp = this.UseScp;
            }

            if (ssi == null)
            {
                Log.WarnFormat("Could not determine session or host to connect.  SessionId or Host or PuttySession must be provided");
            }

            return ssi;
        }