Generated app id with hashed input data (#715)

This commit is contained in:
Brad Richardson
2023-01-07 09:42:40 -05:00
committed by GitHub
parent effa98f76a
commit 9b6d0b7a06
5 changed files with 132 additions and 83 deletions

View File

@@ -30,7 +30,6 @@
#include "network.h"
#include "nvhttp.h"
#include "platform/common.h"
#include "rand.h"
#include "rtsp.h"
#include "utility.h"
#include "uuid.h"
@@ -303,11 +302,6 @@ void saveApp(resp_https_t response, req_https_t request) {
response->write(data.str());
});
std::set<std::string> ids;
for(auto const &app : proc::proc.get_apps()) {
ids.insert(app.id);
}
pt::ptree inputTree, fileTree;
BOOST_LOG(fatal) << config::stream.file_apps;
@@ -316,14 +310,6 @@ void saveApp(resp_https_t response, req_https_t request) {
pt::read_json(ss, inputTree);
pt::read_json(config::stream.file_apps, fileTree);
// Moonlight checks the id of an item to determine if an item was changed
// Needs to be a 32-bit positive integer due to client limitations, "0" indicates no app
auto id = util::generate_int32(1, std::numeric_limits<std::int32_t>::max());
while(ids.count(std::to_string(id)) > 0) {
id = util::generate_int32(1, std::numeric_limits<std::int32_t>::max());
}
inputTree.put("id", id);
if(inputTree.get_child("prep-cmd").empty()) {
inputTree.erase("prep-cmd");
}