Skip to content

Commit

Permalink
During unpairing, also remove cert from client.certs
Browse files Browse the repository at this point in the history
  • Loading branch information
xanderfrangos committed Jan 20, 2024
1 parent c8d74f2 commit 2e7655b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
29 changes: 22 additions & 7 deletions src/nvhttp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1162,18 +1162,33 @@ namespace nvhttp {
* nvhttp::unpair_client("4D7BB2DD-5704-A405-B41C-891A022932E1");
* ```
*/
bool
int
unpair_client(std::string uniqueID) {
int removed = 0;
for (auto &[_, client] : map_id_client) {
for (auto it = client.named_certs.begin(); it != client.named_certs.end();)
{
if ((*it).uniqueID == uniqueID)
for (auto it = client.named_certs.begin(); it != client.named_certs.end();) {
if ((*it).uniqueID == uniqueID) {
// Find matching cert and remove it
for (auto cert = client.certs.begin(); cert != client.certs.end();) {
if ((*cert) == (*it).cert) {
cert = client.certs.erase(cert);
removed++;
}
else {
++cert;
}
}

// And then remove the named cert
it = client.named_certs.erase(it);
else
removed++;
}
else {
++it;
}
}
}
}
save_state();
return true;
return removed;
}
} // namespace nvhttp
2 changes: 1 addition & 1 deletion src/nvhttp.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ namespace nvhttp {
start();
bool
pin(std::string pin, std::string name);
bool
int
unpair_client(std::string uniqueid);
boost::property_tree::ptree
get_all_clients();
Expand Down

0 comments on commit 2e7655b

Please sign in to comment.