Ejemplo n.º 1
0
        private void ThrowVersionMismatchException(string version, SSHProtocol client)
        {
            StringBuilder bld = new StringBuilder();

            bld.Append("The protocol version of the server [");
            bld.Append(version);
            bld.Append("] is not compatible with ");
            bld.Append(client.ToString());
            ThrowSSHException(bld.ToString());
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Verify server version
        /// </summary>
        /// <param name="protocol">expected protocol version</param>
        /// <exception cref="SSHException">server version doesn't match</exception>
        public void Verify(SSHProtocol protocol)
        {
            if (_serverVersion == null)
            {
                throw new SSHException(Strings.GetString("NotSSHServer"));
            }

            string[] sv = _serverVersion.Split('-');
            if (sv.Length >= 3 && sv[0] == "SSH")
            {
                string   protocolVersion = sv[1];
                string[] pv = protocolVersion.Split('.');
                if (pv.Length >= 2)
                {
                    if (protocol == SSHProtocol.SSH1)
                    {
                        if (pv[0] == "1")
                        {
                            return; // OK
                        }
                    }
                    else if (protocol == SSHProtocol.SSH2)
                    {
                        if (pv[0] == "2" || (pv[0] == "1" && pv[1] == "99"))
                        {
                            return; // OK
                        }
                    }
                    throw new SSHException(
                              String.Format(Strings.GetString("IncompatibleProtocolVersion"), _serverVersion, protocol.ToString()));
                }
            }

            throw new SSHException(
                      String.Format(Strings.GetString("InvalidServerVersionFormat"), _serverVersion));
        }
Ejemplo n.º 3
0
 private void ThrowVersionMismatchException(string version, SSHProtocol client) {
     StringBuilder bld = new StringBuilder();
     bld.Append("The protocol version of the server [");
     bld.Append(version);
     bld.Append("] is not compatible with ");
     bld.Append(client.ToString());
     ThrowSSHException(bld.ToString());
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Verify server version
        /// </summary>
        /// <param name="protocol">expected protocol version</param>
        /// <exception cref="SSHException">server version doesn't match</exception>
        public void Verify(SSHProtocol protocol)
        {
            if (_serverVersion == null) {
                throw new SSHException(Strings.GetString("NotSSHServer"));
            }

            string[] sv = _serverVersion.Split('-');
            if (sv.Length >= 3 && sv[0] == "SSH") {
                string protocolVersion = sv[1];
                string[] pv = protocolVersion.Split('.');
                if (pv.Length >= 2) {
                    if (protocol == SSHProtocol.SSH1) {
                        if (pv[0] == "1") {
                            return; // OK
                        }
                    }
                    else if (protocol == SSHProtocol.SSH2) {
                        if (pv[0] == "2" || (pv[0] == "1" && pv[1] == "99")) {
                            return; // OK
                        }
                    }
                    throw new SSHException(
                        String.Format(Strings.GetString("IncompatibleProtocolVersion"), _serverVersion, protocol.ToString()));
                }
            }

            throw new SSHException(
                String.Format(Strings.GetString("InvalidServerVersionFormat"), _serverVersion));
        }