feat: Update 7 files
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include "output.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <filesystem>
|
||||
|
||||
@@ -37,8 +38,31 @@ namespace dropshell
|
||||
return localpath::agent_local() + "/bb64";
|
||||
}
|
||||
|
||||
std::string agent_hash()
|
||||
{
|
||||
return localpath::agent_remote() + "/agent.hash";
|
||||
}
|
||||
|
||||
} // namespace localfile
|
||||
|
||||
std::string get_local_agent_hash()
|
||||
{
|
||||
std::string hash_file = localfile::agent_hash();
|
||||
if (!std::filesystem::exists(hash_file))
|
||||
return "";
|
||||
|
||||
std::ifstream f(hash_file);
|
||||
if (!f.is_open())
|
||||
return "";
|
||||
|
||||
std::string hash;
|
||||
std::getline(f, hash);
|
||||
// Trim whitespace
|
||||
hash.erase(0, hash.find_first_not_of(" \t\n\r"));
|
||||
hash.erase(hash.find_last_not_of(" \t\n\r") + 1);
|
||||
return hash;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------
|
||||
|
||||
namespace localpath
|
||||
|
||||
@@ -56,8 +56,12 @@ namespace dropshell {
|
||||
std::string server_json(const std::string &server_name);
|
||||
std::string service_env(const std::string &server_name, const std::string &service_name);
|
||||
std::string bb64();
|
||||
std::string agent_hash(); // Returns path to agent.hash file
|
||||
} // namespace localfile
|
||||
|
||||
// Get the content of the local agent hash (empty string if not found)
|
||||
std::string get_local_agent_hash();
|
||||
|
||||
namespace localpath {
|
||||
std::string dropshell_dir();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user