mirror of
https://github.com/asdlokj1qpi233/subconverter.git
synced 2026-11-03 10:12:50 +00:00
Enhancements
Add support for Quantumult X IP6-CIDR rules. Add SNI host settings to Surge VMess nodes.
This commit is contained in:
3 files changed
+21
-17
No files matched your search
+4
-2
@@ -138,7 +138,7 @@ std::string getRuleset(RESPONSE_CALLBACK_ARGS)
|
|||||||
switch(type_int)
|
switch(type_int)
|
||||||
{
|
{
|
||||||
case 2:
|
case 2:
|
||||||
if(!std::any_of(quanx_rule_type.begin(), quanx_rule_type.end(), [&strLine](std::string type){return startsWith(strLine, type);}) || startsWith(strLine, "IP-CIDR6"))
|
if(!std::any_of(quanx_rule_type.begin(), quanx_rule_type.end(), [&strLine](std::string type){return startsWith(strLine, type);}))
|
||||||
continue;
|
continue;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
@@ -206,6 +206,8 @@ std::string getRuleset(RESPONSE_CALLBACK_ARGS)
|
|||||||
{
|
{
|
||||||
if(type_int == 2)
|
if(type_int == 2)
|
||||||
{
|
{
|
||||||
|
if(startsWith(strLine, "IP-CIDR6"))
|
||||||
|
strLine.replace(0, 8, "IP6-CIDR");
|
||||||
strLine += "," + group;
|
strLine += "," + group;
|
||||||
if(std::count(strLine.begin(), strLine.end(), ',') > 2 && regReplace(strLine, rule_match_regex, "$2") == ",no-resolve")
|
if(std::count(strLine.begin(), strLine.end(), ',') > 2 && regReplace(strLine, rule_match_regex, "$2") == ",no-resolve")
|
||||||
strLine = regReplace(strLine, rule_match_regex, "$1$3$2");
|
strLine = regReplace(strLine, rule_match_regex, "$1$3$2");
|
||||||
@@ -1954,7 +1956,7 @@ std::string getProfile(RESPONSE_CALLBACK_ARGS)
|
|||||||
return "Broken profile!";
|
return "Broken profile!";
|
||||||
}
|
}
|
||||||
auto profile_token = contents.find("profile_token");
|
auto profile_token = contents.find("profile_token");
|
||||||
if(profile_token != contents.end())
|
if(profiles.size() == 1 && profile_token != contents.end())
|
||||||
{
|
{
|
||||||
if(token != profile_token->second)
|
if(token != profile_token->second)
|
||||||
{
|
{
|
||||||
|
|||||||
+9
-12
@@ -2124,18 +2124,15 @@ static inline unsigned long long streamToInt(const std::string &stream)
|
|||||||
if(!stream.size())
|
if(!stream.size())
|
||||||
return 0;
|
return 0;
|
||||||
double streamval = 1.0;
|
double streamval = 1.0;
|
||||||
if(stream.find("GB") != std::string::npos)
|
std::vector<std::string> units = {"B", "KB", "MB", "GB", "TB", "PB", "EB"};
|
||||||
streamval = std::pow(1024, 3) * to_number<float>(stream.substr(0, stream.size() - 2), 0.0);
|
for(size_t index = units.size() - 1; index >= 0; index--)
|
||||||
else if(stream.find("TB") != std::string::npos)
|
{
|
||||||
streamval = std::pow(1024, 4) * to_number<float>(stream.substr(0, stream.size() - 2), 0.0);
|
if(endsWith(stream, units[index]))
|
||||||
else if(stream.find("PB") != std::string::npos)
|
{
|
||||||
streamval = std::pow(1024, 5) * to_number<float>(stream.substr(0, stream.size() - 2), 0.0);
|
streamval = std::pow(1024, index) * to_number<float>(stream.substr(0, stream.size() - units[index].size()), 0.0);
|
||||||
else if(stream.find("MB") != std::string::npos)
|
break;
|
||||||
streamval = std::pow(1024, 2) * to_number<float>(stream.substr(0, stream.size() - 2), 0.0);
|
}
|
||||||
else if(stream.find("KB") != std::string::npos)
|
}
|
||||||
streamval = 1024.0 * to_number<float>(stream.substr(0, stream.size() - 2), 0.0);
|
|
||||||
else if(stream.find("B") != std::string::npos)
|
|
||||||
streamval = 1.0 * to_number<float>(stream.substr(0, stream.size() - 1), 0.0);
|
|
||||||
return (unsigned long long)streamval;
|
return (unsigned long long)streamval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+8
-3
@@ -834,9 +834,12 @@ void rulesetToSurge(INIReader &base_rule, std::vector<ruleset_content> &ruleset_
|
|||||||
/// remove unsupported types
|
/// remove unsupported types
|
||||||
switch(surge_ver)
|
switch(surge_ver)
|
||||||
{
|
{
|
||||||
case -1:
|
|
||||||
case -2:
|
case -2:
|
||||||
if(!std::any_of(quanx_rule_type.begin(), quanx_rule_type.end(), [strLine](std::string type){return startsWith(strLine, type);}) || startsWith(strLine, "IP-CIDR6"))
|
if(startsWith(strLine, "IP-CIDR6"))
|
||||||
|
continue;
|
||||||
|
[[fallthrough]];
|
||||||
|
case -1:
|
||||||
|
if(!std::any_of(quanx_rule_type.begin(), quanx_rule_type.end(), [strLine](std::string type){return startsWith(strLine, type);}))
|
||||||
continue;
|
continue;
|
||||||
break;
|
break;
|
||||||
case -3:
|
case -3:
|
||||||
@@ -859,6 +862,8 @@ void rulesetToSurge(INIReader &base_rule, std::vector<ruleset_content> &ruleset_
|
|||||||
strLine += "," + rule_group;
|
strLine += "," + rule_group;
|
||||||
if(surge_ver == -1 || surge_ver == -2)
|
if(surge_ver == -1 || surge_ver == -2)
|
||||||
{
|
{
|
||||||
|
if(startsWith(strLine, "IP-CIDR6"))
|
||||||
|
strLine.replace(0, 8, "IP6-CIDR");
|
||||||
if(std::count(strLine.begin(), strLine.end(), ',') > 2 && regReplace(strLine, rule_match_regex, "$2") == ",no-resolve")
|
if(std::count(strLine.begin(), strLine.end(), ',') > 2 && regReplace(strLine, rule_match_regex, "$2") == ",no-resolve")
|
||||||
strLine = regReplace(strLine, rule_match_regex, "$1$3$2");
|
strLine = regReplace(strLine, rule_match_regex, "$1$3$2");
|
||||||
else
|
else
|
||||||
@@ -1388,7 +1393,7 @@ std::string netchToSurge(std::vector<nodeInfo> &nodes, std::string &base_conf, s
|
|||||||
case "tcp"_hash:
|
case "tcp"_hash:
|
||||||
break;
|
break;
|
||||||
case "ws"_hash:
|
case "ws"_hash:
|
||||||
proxy += ", ws=true, ws-path=" + path + ", ws-headers=Host:" + host;
|
proxy += ", ws=true, ws-path=" + path + ", sni=" + host + ", ws-headers=Host:" + host;
|
||||||
if(edge.size())
|
if(edge.size())
|
||||||
proxy += "|Edge:" + edge;
|
proxy += "|Edge:" + edge;
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in new issue
Block a user