1 class SshHosts { 2 public: 3 struct Info { 4 String key; 5 int type; 6 int status; 7 IsRSAInfo8 bool IsRSA() const { return type == LIBSSH2_KNOWNHOST_KEY_SSHRSA; } IsDSSInfo9 bool IsDSS() const { return type == LIBSSH2_KNOWNHOST_KEY_SSHDSS; } IsUnknownInfo10 bool IsUnknown() const { return !IsRSA() && !IsDSS(); } 11 IsFailureInfo12 bool IsFailure() const { return status == LIBSSH2_KNOWNHOST_CHECK_FAILURE; } IsNotFoundInfo13 bool IsNotFound() const { return status == LIBSSH2_KNOWNHOST_CHECK_NOTFOUND; } IsMismatchInfo14 bool IsMismatch() const { return status == LIBSSH2_KNOWNHOST_CHECK_MISMATCH; } IsMatchInfo15 bool IsMatch() const { return status == LIBSSH2_KNOWNHOST_CHECK_MATCH; } 16 }; 17 18 public: 19 bool Add(const String& host, int port, const Info& info, const String& comment); 20 bool Add(const String& host, const Info& info, const String& comment); 21 bool Remove(SshHost* host); 22 bool Load(const String& filename); 23 bool Save(); 24 bool SaveAs(const String& filename); 25 Info Check(const String& host, int port); 26 27 Vector<SshHost*> GetHosts(); 28 GetError()29 int GetError() const { return error.a; } GetErrorDesc()30 String GetErrorDesc() const { return error.b; } 31 32 SshHosts(SshSession& session); 33 virtual ~SshHosts(); 34 35 private: 36 bool Error(); Clear()37 void Clear() { error.a = 0; error.b = Null; } 38 39 String file_path; 40 Tuple<int,String> error; 41 LIBSSH2_SESSION* ssh_session; 42 LIBSSH2_KNOWNHOSTS* handle; 43 }; 44