/// <summary>Initialize SSH session</summary> /// <exception cref="NGit.Errors.TransportException">in case of error with opening SSH session /// </exception> protected internal virtual void InitSession() { if (sock != null) { return; } int tms = GetTimeout() > 0 ? GetTimeout() * 1000 : 0; string user = uri.GetUser(); string pass = uri.GetPass(); string host = uri.GetHost(); int port = uri.GetPort(); try { sock = sch.GetSession(user, pass, host, port, GetCredentialsProvider(), local.FileSystem ); if (!sock.IsConnected()) { sock.Connect(tms); } } catch (JSchException je) { Exception c = je.InnerException; if (c is UnknownHostException) { throw new TransportException(uri, JGitText.Get().unknownHost); } if (c is ConnectException) { throw new TransportException(uri, c.Message); } throw new TransportException(uri, je.Message, je); } }
/// <summary>Get the default SSH session</summary> /// <returns>a remote session</returns> /// <exception cref="NGit.Errors.TransportException">in case of error with opening SSH session /// </exception> protected internal virtual RemoteSession GetSession() { if (sock != null) { return(sock); } int tms = GetTimeout() > 0 ? GetTimeout() * 1000 : 0; sock = sch.GetSession(uri, GetCredentialsProvider(), local.FileSystem, tms); return(sock); }