mirror of
https://github.com/asdlokj1qpi233/subconverter.git
synced 2026-11-04 10:42:04 +00:00
Enhancements
Fix support for converting Quantumult X rulesets to Surge format. Add support for exporting Trojan nodes to Loon configurations. Optimize codes.
This commit is contained in:
3 files changed
+18
-10
No files matched your search
+2
-2
@@ -161,8 +161,8 @@ std::string convertRuleset(const std::string &content, int type)
|
|||||||
}
|
}
|
||||||
else /// QuanX
|
else /// QuanX
|
||||||
{
|
{
|
||||||
output = regReplace(regReplace(content, "(?i:host)", "DOMAIN", true), "(?i:ip6-cidr)", "IP-CIDR6", true); //translate type
|
output = regReplace(regReplace(content, "^(?i:host)", "DOMAIN", true), "^(?i:ip6-cidr)", "IP-CIDR6", true); //translate type
|
||||||
output = regReplace(output, "^((?i:DOMAIN(?:-(?:SUFFIX|KEYWORD))?|IP-CIDR6?),.*?)(?:,(?!no-resolve).*?)(,no-resolve)?$", "$1$2", true); //remove group
|
output = regReplace(output, "^((?i:DOMAIN(?:-(?:SUFFIX|KEYWORD))?|IP-CIDR6?|USER-AGENT),)\\s*?(\\S*?)(?:,(?!no-resolve).*?)(,no-resolve)?$", "\\U$1\\E$2${3:-}", true); //remove group
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-8
@@ -658,28 +658,28 @@ int regGetMatch(const std::string &src, const std::string &match, size_t group_c
|
|||||||
bool regMatch(const std::string &src, const std::string &match)
|
bool regMatch(const std::string &src, const std::string &match)
|
||||||
{
|
{
|
||||||
jp::Regex reg;
|
jp::Regex reg;
|
||||||
reg.setPattern(match).addModifier("gm").addPcre2Option(PCRE2_ANCHORED|PCRE2_ENDANCHORED|PCRE2_UTF).compile();
|
reg.setPattern(match).addModifier("m").addPcre2Option(PCRE2_ANCHORED|PCRE2_ENDANCHORED|PCRE2_UTF).compile();
|
||||||
if(!reg)
|
if(!reg)
|
||||||
return false;
|
return false;
|
||||||
return reg.match(src);
|
return reg.match(src, "g");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool regFind(const std::string &src, const std::string &match)
|
bool regFind(const std::string &src, const std::string &match)
|
||||||
{
|
{
|
||||||
jp::Regex reg;
|
jp::Regex reg;
|
||||||
reg.setPattern(match).addModifier("gm").addPcre2Option(PCRE2_UTF).compile();
|
reg.setPattern(match).addModifier("m").addPcre2Option(PCRE2_UTF).compile();
|
||||||
if(!reg)
|
if(!reg)
|
||||||
return false;
|
return false;
|
||||||
return reg.match(src);
|
return reg.match(src, "g");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string regReplace(const std::string &src, const std::string &match, const std::string &rep, bool global)
|
std::string regReplace(const std::string &src, const std::string &match, const std::string &rep, bool global)
|
||||||
{
|
{
|
||||||
jp::Regex reg;
|
jp::Regex reg;
|
||||||
reg.setPattern(match).addModifier("gm").addPcre2Option(PCRE2_UTF).compile();
|
reg.setPattern(match).addModifier("m").addPcre2Option(PCRE2_UTF|PCRE2_MULTILINE).compile();
|
||||||
if(!reg)
|
if(!reg)
|
||||||
return src;
|
return src;
|
||||||
return reg.replace(src, rep, global ? "g" : "");
|
return reg.replace(src, rep, global ? "gx" : "x");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool regValid(const std::string ®)
|
bool regValid(const std::string ®)
|
||||||
@@ -691,10 +691,10 @@ bool regValid(const std::string ®)
|
|||||||
int regGetMatch(const std::string &src, const std::string &match, size_t group_count, ...)
|
int regGetMatch(const std::string &src, const std::string &match, size_t group_count, ...)
|
||||||
{
|
{
|
||||||
jp::Regex reg;
|
jp::Regex reg;
|
||||||
reg.setPattern(match).addModifier("gm").addPcre2Option(PCRE2_UTF).compile();
|
reg.setPattern(match).addModifier("m").addPcre2Option(PCRE2_UTF).compile();
|
||||||
jp::VecNum vec_num;
|
jp::VecNum vec_num;
|
||||||
jp::RegexMatch rm;
|
jp::RegexMatch rm;
|
||||||
size_t count = rm.setRegexObject(®).setSubject(src).setNumberedSubstringVector(&vec_num).match();
|
size_t count = rm.setRegexObject(®).setSubject(src).setNumberedSubstringVector(&vec_num).setModifier("g").match();
|
||||||
if(!count)
|
if(!count)
|
||||||
return -1;
|
return -1;
|
||||||
va_list vl;
|
va_list vl;
|
||||||
|
|||||||
@@ -2851,6 +2851,14 @@ std::string netchToLoon(std::vector<nodeInfo> &nodes, std::string &base_conf, st
|
|||||||
case SPEEDTEST_MESSAGE_FOUNDHTTP:
|
case SPEEDTEST_MESSAGE_FOUNDHTTP:
|
||||||
proxy = "http," + hostname + "," + port + "," + username + "," + password;
|
proxy = "http," + hostname + "," + port + "," + username + "," + password;
|
||||||
break;
|
break;
|
||||||
|
case SPEEDTEST_MESSAGE_FOUNDTROJAN:
|
||||||
|
host = GetMember(json, "Host");
|
||||||
|
proxy = "trojan," + hostname + "," + port + "," + password;
|
||||||
|
if(host.size())
|
||||||
|
proxy += ",tls-name:" + host;
|
||||||
|
if(scv)
|
||||||
|
proxy += ",skip-cert-verify:1";
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user