Configure prevention pairing over non-private network
This commit is contained in:
@@ -36,12 +36,13 @@ stream_t stream {
|
||||
};
|
||||
|
||||
nvhttp_t nvhttp {
|
||||
"lan", // origin_pin
|
||||
PRIVATE_KEY_FILE,
|
||||
CERTIFICATE_FILE,
|
||||
|
||||
"sunshine", // sunshine_name
|
||||
"03904e64-51da-4fb3-9afd-a9f7ff70fea4", // unique_id
|
||||
"devices.json" // file_devices
|
||||
"sunshine"s, // sunshine_name,
|
||||
"03904e64-51da-4fb3-9afd-a9f7ff70fea4"s, // unique_id
|
||||
"devices.json"s // file_devices
|
||||
};
|
||||
|
||||
input_t input {
|
||||
@@ -102,6 +103,32 @@ void string_f(std::unordered_map<std::string, std::string> &vars, const std::str
|
||||
input = std::move(it->second);
|
||||
}
|
||||
|
||||
void string_restricted_f(std::unordered_map<std::string, std::string> &vars, const std::string &name, std::string &input, const std::vector<std::string_view> &allowed_vals) {
|
||||
std::string temp;
|
||||
string_f(vars, name, temp);
|
||||
|
||||
for(auto &allowed_val : allowed_vals) {
|
||||
if(temp == allowed_val) {
|
||||
input = std::move(temp);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void int_restricted_f(std::unordered_map<std::string, std::string> &vars, const std::string &name, int &input, const std::vector<std::string_view> &allowed_vals) {
|
||||
std::string temp;
|
||||
string_f(vars, name, temp);
|
||||
|
||||
for(int x = 0; x < allowed_vals.size(); ++x) {
|
||||
auto &allowed_val = allowed_vals[x];
|
||||
|
||||
if(temp == allowed_val) {
|
||||
input = x;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void int_f(std::unordered_map<std::string, std::string> &vars, const std::string &name, int &input) {
|
||||
auto it = vars.find(name);
|
||||
|
||||
@@ -142,6 +169,10 @@ void parse_file(const char *file) {
|
||||
string_f(vars, "file_devices", nvhttp.file_devices);
|
||||
string_f(vars, "external_ip", nvhttp.external_ip);
|
||||
|
||||
string_restricted_f(vars, "origin_pin_allowed", nvhttp.origin_pin_allowed, {
|
||||
"pc"sv, "lan"sv, "wan"sv
|
||||
});
|
||||
|
||||
int to = -1;
|
||||
int_f(vars, "ping_timeout", to);
|
||||
if(to > 0) {
|
||||
|
||||
Reference in New Issue
Block a user