Enhancement

Add support for keeping the original order of proxies when parsing Surge/Quantumult X subscriptions.
This commit is contained in:
Tindy X committed 2020-03-09 13:06:18 +08:00
1 parent 7bbd9af989
commit 98599f3b61
1 file changed
+6 -3
+6 -3
View File
@@ -1050,6 +1050,7 @@ bool explodeSurge(std::string surge, std::string custom_port, int local_port, st
ini.keep_empty_section = false; ini.keep_empty_section = false;
ini.SetIsolatedItemsSection("Proxy"); ini.SetIsolatedItemsSection("Proxy");
ini.IncludeSection("Proxy"); ini.IncludeSection("Proxy");
ini.AddDirectSaveSection("Proxy");
ini.Parse(surge); ini.Parse(surge);
if(!ini.SectionExist("Proxy")) if(!ini.SectionExist("Proxy"))
@@ -1057,6 +1058,8 @@ bool explodeSurge(std::string surge, std::string custom_port, int local_port, st
ini.EnterSection("Proxy"); ini.EnterSection("Proxy");
ini.GetItems(proxies); ini.GetItems(proxies);
const std::string proxystr = "(.*?)\\s*=\\s*(.*)";
for(auto &x : proxies) for(auto &x : proxies)
{ {
std::string remarks, server, port, method, username, password; //common std::string remarks, server, port, method, username, password; //common
@@ -1066,11 +1069,11 @@ bool explodeSurge(std::string surge, std::string custom_port, int local_port, st
std::string itemName, itemVal; std::string itemName, itemVal;
std::vector<std::string> configs, vArray, headers, header; std::vector<std::string> configs, vArray, headers, header;
remarks = x.first; remarks = regReplace(x.second, proxystr, "$1");
configs = split(x.second, ","); configs = split(regReplace(x.second, proxystr, "$2"), ",");
if(configs.size() < 2 || configs[0] == "direct") if(configs.size() < 2 || configs[0] == "direct")
continue; continue;
else if(configs[0] == "custom") //surge 2 style custom proxy if(configs[0] == "custom") //surge 2 style custom proxy
{ {
//remove module detection to speed up parsing and compatible with broken module //remove module detection to speed up parsing and compatible with broken module
/* /*