#pragma once #include #include #include // Who the SSH App connects to, and which servers it has met (issue #2, N1 Q262 and Q263): kept // in the device's settings as a few lines of text. namespace roro::term { struct SshTarget { std::string user, host; uint16_t port = 22; std::string text() const; // user@host, with :port when it isn't 22 std::string hostPort() const; // host:port, always: what a host key is remembered under }; // "user@host", "user@host:2222". "" or what is wrong with it. std::string parseSshTarget(const std::string& text, SshTarget& out); // Up to eight, the last used first; one a line. class SshHosts { public: static constexpr size_t kMax = 8; explicit SshHosts(const std::string& stored = ""); const std::vector& list() const { return hosts_; } void used(const SshTarget& target); // to the front, added if it's new void remove(size_t index); std::string stored() const; private: std::vector hosts_; }; // The fingerprint each server showed the first time: "host:port SHA256:...", one a line, sixteen // at most (the oldest goes). class SshKnownHosts { public: static constexpr size_t kMax = 16; explicit SshKnownHosts(const std::string& stored = ""); std::string fingerprintOf(const std::string& hostPort) const; // "" if never met void remember(const std::string& hostPort, const std::string& fingerprint); void forget(const std::string& hostPort); std::string stored() const; private: std::vector> known_; }; } // namespace roro::term