Fix support for some non-standard Shadowsocks subscriptions

This commit is contained in:
Tindy X committed 2020-06-02 12:31:28 +08:00
1 parent 226c9a4db7
commit ac11260747
1 file changed
+12 -8
+12 -8
View File
@@ -477,21 +477,25 @@ void explodeSSConf(std::string content, const std::string &custom_port, bool lib
json.Parse(content.data()); json.Parse(content.data());
if(json.HasParseError()) if(json.HasParseError())
return; return;
const char *section = json.HasMember("version") && json.HasMember("remarks") && json.HasMember("servers") ? "servers" : "configs";
if(!json.HasMember(section))
return;
GetMember(json, "remarks", group);
for(unsigned int i = 0; i < json["configs"].Size(); i++) for(unsigned int i = 0; i < json[section].Size(); i++)
{ {
json["configs"][i]["remarks"] >> ps; ps = GetMember(json[section][i], "remarks");
port = custom_port.size() ? custom_port : GetMember(json["configs"][i], "server_port"); port = custom_port.size() ? custom_port : GetMember(json[section][i], "server_port");
if(port == "0") if(port == "0")
continue; continue;
if(ps.empty()) if(ps.empty())
ps = server + ":" + port; ps = server + ":" + port;
json["configs"][i]["password"] >> password; password = GetMember(json[section][i], "password");
json["configs"][i]["method"] >> method; method = GetMember(json[section][i], "method");
json["configs"][i]["server"] >> server; server = GetMember(json[section][i], "server");
json["configs"][i]["plugin"] >> plugin; plugin = GetMember(json[section][i], "plugin");
json["configs"][i]["plugin_opts"] >> pluginopts; pluginopts = GetMember(json[section][i], "plugin_opts");
node.linkType = SPEEDTEST_MESSAGE_FOUNDSS; node.linkType = SPEEDTEST_MESSAGE_FOUNDSS;
node.group = group; node.group = group;