mirror of
https://github.com/asdlokj1qpi233/subconverter.git
synced 2026-11-02 01:33:04 +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)
|
||||
{
|
||||
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;
|
||||
break;
|
||||
case 1:
|
||||
@@ -206,6 +206,8 @@ std::string getRuleset(RESPONSE_CALLBACK_ARGS)
|
||||
{
|
||||
if(type_int == 2)
|
||||
{
|
||||
if(startsWith(strLine, "IP-CIDR6"))
|
||||
strLine.replace(0, 8, "IP6-CIDR");
|
||||
strLine += "," + group;
|
||||
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");
|
||||
@@ -1954,7 +1956,7 @@ std::string getProfile(RESPONSE_CALLBACK_ARGS)
|
||||
return "Broken profile!";
|
||||
}
|
||||
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)
|
||||
{
|
||||
|
||||
+9
-12
@@ -2124,18 +2124,15 @@ static inline unsigned long long streamToInt(const std::string &stream)
|
||||
if(!stream.size())
|
||||
return 0;
|
||||
double streamval = 1.0;
|
||||
if(stream.find("GB") != std::string::npos)
|
||||
streamval = std::pow(1024, 3) * to_number<float>(stream.substr(0, stream.size() - 2), 0.0);
|
||||
else if(stream.find("TB") != std::string::npos)
|
||||
streamval = std::pow(1024, 4) * to_number<float>(stream.substr(0, stream.size() - 2), 0.0);
|
||||
else if(stream.find("PB") != std::string::npos)
|
||||
streamval = std::pow(1024, 5) * to_number<float>(stream.substr(0, stream.size() - 2), 0.0);
|
||||
else if(stream.find("MB") != std::string::npos)
|
||||
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);
|
||||
std::vector<std::string> units = {"B", "KB", "MB", "GB", "TB", "PB", "EB"};
|
||||
for(size_t index = units.size() - 1; index >= 0; index--)
|
||||
{
|
||||
if(endsWith(stream, units[index]))
|
||||
{
|
||||
streamval = std::pow(1024, index) * to_number<float>(stream.substr(0, stream.size() - units[index].size()), 0.0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return (unsigned long long)streamval;
|
||||
}
|
||||
|
||||
|
||||
+8
-3
@@ -834,9 +834,12 @@ void rulesetToSurge(INIReader &base_rule, std::vector<ruleset_content> &ruleset_
|
||||
/// remove unsupported types
|
||||
switch(surge_ver)
|
||||
{
|
||||
case -1:
|
||||
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;
|
||||
break;
|
||||
case -3:
|
||||
@@ -859,6 +862,8 @@ void rulesetToSurge(INIReader &base_rule, std::vector<ruleset_content> &ruleset_
|
||||
strLine += "," + rule_group;
|
||||
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")
|
||||
strLine = regReplace(strLine, rule_match_regex, "$1$3$2");
|
||||
else
|
||||
@@ -1388,7 +1393,7 @@ std::string netchToSurge(std::vector<nodeInfo> &nodes, std::string &base_conf, s
|
||||
case "tcp"_hash:
|
||||
break;
|
||||
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())
|
||||
proxy += "|Edge:" + edge;
|
||||
break;
|
||||
|
||||
Reference in new issue
Block a user