mirror of
https://github.com/MetaCubeX/subconverter.git
synced 2025-11-04 18:19:42 +08:00
Add remotely update configuration via Web interface
This commit is contained in:
parent
71bfd953f1
commit
526de55095
21
main.cpp
21
main.cpp
@ -525,6 +525,27 @@ int main(int argc, char *argv[])
|
||||
return "done";
|
||||
});
|
||||
|
||||
append_response("POST", "/updateconf", "text/plain", [](RESPONSE_CALLBACK_ARGS) -> std::string
|
||||
{
|
||||
if(access_token.size())
|
||||
{
|
||||
std::string token = getUrlArg(argument, "token");
|
||||
if(token != access_token)
|
||||
return "Unauthorized";
|
||||
}
|
||||
std::string type = getUrlArg(argument, "type");
|
||||
if(type == "form")
|
||||
fileWrite(pref_path, getFormData(postdata), true);
|
||||
else if(type == "direct")
|
||||
fileWrite(pref_path, postdata, true);
|
||||
else
|
||||
return "Not implemented";
|
||||
readConf();
|
||||
if(!update_ruleset_on_request)
|
||||
refreshRulesets(rulesets, ruleset_content_array);
|
||||
return "done";
|
||||
});
|
||||
|
||||
append_response("GET", "/sub", "text/plain;charset=utf-8", subconverter);
|
||||
|
||||
append_response("GET", "/clash", "text/plain;charset=utf-8", [](RESPONSE_CALLBACK_ARGS) -> std::string
|
||||
|
||||
Loading…
Reference in New Issue
Block a user