[feat] unify Windows unattended hosting and device identity

This commit is contained in:
dijunkun
2026-11-10 10:43:43 +08:00
parent 930ccd9ea1
commit 4e2532f33c
67 changed files with 3491 additions and 941 deletions
@@ -230,4 +230,16 @@ void TrustedDevices::Remove(const std::string& public_key) {
Save(next);
devices_.swap(next);
}
void TrustedDevices::Replace(const std::vector<Device>& devices) {
Require(devices.size() <= kMaxTrustedDevices);
std::map<std::string, Device> next;
for (const auto& device : devices) {
Require(IsHex(device.public_key, 32) && Label(device.name) && Label(device.device_id));
Require(next.emplace(device.public_key, device).second);
}
std::lock_guard lock(mutex_);
if (next == devices_) return;
Save(next);
devices_.swap(next);
}
} // namespace crossdesk