Enhancements

Fix compatibility problem with some non-standard subscriptions.
Add support for specifying token for each profile.
This commit is contained in:
Tindy X committed 2020-03-09 12:28:24 +08:00
1 parent 4eda0edb26
commit 7bbd9af989
2 files changed
+47 -28

No files matched your search

+19 -1
View File
@@ -1664,7 +1664,7 @@ std::string surgeConfToClash(RESPONSE_CALLBACK_ARGS)
std::string getProfile(RESPONSE_CALLBACK_ARGS)
{
std::string name = UrlDecode(getUrlArg(argument, "name")), token = UrlDecode(getUrlArg(argument, "token")), expand = getUrlArg(argument, "expand");
if(token != access_token)
if(token.empty() || name.empty())
{
*status_code = 403;
return "Forbidden";
@@ -1695,6 +1695,24 @@ std::string getProfile(RESPONSE_CALLBACK_ARGS)
*status_code = 500;
return "Broken profile!";
}
auto profile_token = contents.find("profile_token");
if(profile_token != contents.end())
{
if(token != profile_token->second)
{
*status_code = 403;
return "Forbidden";
}
token = access_token;
}
else
{
if(token != access_token)
{
*status_code = 403;
return "Forbidden";
}
}
contents.emplace("token", token);
contents.emplace("expand", expand);
std::string query;