477bcd00f0
- CMakeLists.txt - agent_protocol.cpp - agent_protocol.h - app.md - appicon.ico - hosts_db.cpp - hosts_db.h - http_client.cpp - http_client.h - main.cpp - ... Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
39 lines
743 B
C++
39 lines
743 B
C++
#pragma once
|
|
#include <string>
|
|
#include <vector>
|
|
#include <cstdint>
|
|
|
|
struct sqlite3;
|
|
|
|
namespace pex {
|
|
|
|
struct Host {
|
|
int64_t id = 0;
|
|
std::string name;
|
|
std::string url;
|
|
std::string token;
|
|
std::string os; // "linux" | "windows" | "wsl"
|
|
int64_t last_seen_unix = 0;
|
|
bool is_local = false;
|
|
};
|
|
|
|
class HostsDb {
|
|
public:
|
|
HostsDb();
|
|
~HostsDb();
|
|
|
|
// path debe ser absoluto (fn::local_path("hosts.db")).
|
|
bool open(const std::string& path);
|
|
void close();
|
|
|
|
std::vector<Host> list();
|
|
int64_t upsert(const Host& h); // devuelve id; -1 si falla
|
|
bool remove(int64_t id);
|
|
bool touch_last_seen(int64_t id, int64_t unix_ts);
|
|
|
|
private:
|
|
sqlite3* db_ = nullptr;
|
|
};
|
|
|
|
} // namespace pex
|