Implement asset inventory
This commit is contained in:
+11
@@ -123,6 +123,17 @@ lazy_static::lazy_static! {
|
||||
/// "empty = omit" convention as `AGENT_NAME`. For hello-agent this
|
||||
/// is `env!("CARGO_PKG_VERSION")`.
|
||||
pub static ref AGENT_VERSION: RwLock<String> = RwLock::new(String::new());
|
||||
/// Pre-serialized JSON object describing the host's hardware /
|
||||
/// firmware / OS edition inventory (BIOS serial, manufacturer, model,
|
||||
/// AD domain, OS edition + release, CPU details, RAM, disks,
|
||||
/// BitLocker recovery key). Same "empty = omit" convention as
|
||||
/// `AGENT_NAME`: when non-empty, `hbbs_http::sync` parses it and
|
||||
/// merges it into the sysinfo upload under the `inventory` key, where
|
||||
/// the rustdesk-server admin UI's per-device detail page reads it.
|
||||
/// Stored pre-serialized so the producer (hello-agent's `inventory`
|
||||
/// module) owns the schema and the consumer (sync) doesn't need to
|
||||
/// know the field set.
|
||||
pub static ref INVENTORY: RwLock<String> = RwLock::new(String::new());
|
||||
static ref KEY_PAIR: Mutex<Option<KeyPair>> = Default::default();
|
||||
static ref USER_DEFAULT_CONFIG: RwLock<(UserDefaultConfig, Instant)> = RwLock::new((UserDefaultConfig::load(), Instant::now()));
|
||||
pub static ref NEW_STORED_PEER_CONFIG: Mutex<HashSet<String>> = Default::default();
|
||||
|
||||
+16
@@ -147,6 +147,22 @@ async fn start_hbbs_sync_async() {
|
||||
if !agent_version.is_empty() {
|
||||
v["agent_version"] = json!(agent_version);
|
||||
}
|
||||
// Optional CMDB inventory. Producer (hello-agent's
|
||||
// `inventory` module) populates this with a pre-
|
||||
// serialized JSON object covering BIOS / hardware /
|
||||
// OS-edition fields. We re-parse on each upload (the
|
||||
// string is small — single-digit kB at most) rather
|
||||
// than caching, so a refreshed inventory is picked up
|
||||
// without bookkeeping. Parse failure is silently
|
||||
// dropped: the sysinfo upload still goes out without
|
||||
// the `inventory` key, identical to a vanilla rustdesk
|
||||
// install.
|
||||
let inventory = config::INVENTORY.read().unwrap().clone();
|
||||
if !inventory.is_empty() {
|
||||
if let Ok(inv_v) = serde_json::from_str::<Value>(&inventory) {
|
||||
v["inventory"] = inv_v;
|
||||
}
|
||||
}
|
||||
let ab_name = Config::get_option(keys::OPTION_PRESET_ADDRESS_BOOK_NAME);
|
||||
if !ab_name.is_empty() {
|
||||
v[keys::OPTION_PRESET_ADDRESS_BOOK_NAME] = json!(ab_name);
|
||||
|
||||
Reference in New Issue
Block a user