Add fallback support for different names of Shadowsocks plugins

Fix compatibility problem with some non-standard v2rayN subscription.
Fix running program from directory other than program folder may cause not using pref.yml as default.
Optimize codes.
This commit is contained in:
Tindy X
2020-07-14 03:04:48 +08:00
parent 447f6801d5
commit 3989b7ee5e
5 changed files with 22 additions and 4 deletions

View File

@@ -99,6 +99,10 @@ void signal_handler(int sig)
int main(int argc, char *argv[])
{
#ifndef _DEBUG
std::string prgpath = argv[0];
setcd(prgpath); //first switch to program directory
#endif // _DEBUG
if(fileExist("pref.yml"))
pref_path = "pref.yml";
chkArg(argc, argv);
@@ -125,10 +129,6 @@ int main(int argc, char *argv[])
signal(SIGINT, signal_handler);
SetConsoleTitle("SubConverter " VERSION);
#ifndef _DEBUG
std::string prgpath = argv[0];
setcd(prgpath); //first switch to program directory
#endif // _DEBUG
readConf();
if(!update_ruleset_on_request)
refreshRulesets(rulesets, ruleset_content_array);

View File

@@ -451,6 +451,20 @@ std::string getSystemProxy()
#endif // _WIN32
}
void trim_self_of(std::string &str, char target, bool before, bool after)
{
if (!before && !after)
return;
std::string::size_type pos = str.size() - 1;
if (after)
pos = str.find_last_not_of(target);
if (pos != std::string::npos)
str.erase(pos + 1);
if (before)
pos = str.find_first_not_of(target);
str.erase(0, pos);
}
std::string trim_of(const std::string& str, char target, bool before, bool after)
{
if (!before && !after)

View File

@@ -55,6 +55,7 @@ std::string ACPToUTF8(const std::string &str_src);
std::string trim_of(const std::string& str, char target, bool before = true, bool after = true);
std::string trim(const std::string& str, bool before = true, bool after = true);
std::string trim_quote(const std::string &str, bool before = true, bool after = true);
void trim_self_of(std::string &str, char target, bool before = true, bool after = true);
std::string getSystemProxy();
std::string rand_str(const int len);
bool is_str_utf8(const std::string &data);

View File

@@ -85,6 +85,7 @@ void explodeVmess(std::string vmess, const std::string &custom_port, nodeInfo &n
break;
}
add = trim(add);
node.linkType = SPEEDTEST_MESSAGE_FOUNDVMESS;
node.group = V2RAY_DEFAULT_GROUP;
node.remarks = ps;

View File

@@ -1548,6 +1548,7 @@ std::string netchToSurge(std::vector<nodeInfo> &nodes, const std::string &base_c
switch(hash_(plugin))
{
case "simple-obfs"_hash:
case "obfs-local"_hash:
if(pluginopts.size())
proxy += "," + replace_all_distinct(pluginopts, ";", ",");
break;
@@ -2299,6 +2300,7 @@ void netchToQuanX(std::vector<nodeInfo> &nodes, INIReader &ini, std::vector<rule
switch(hash_(plugin))
{
case "simple-obfs"_hash:
case "obfs-local"_hash:
if(pluginopts.size())
proxyStr += ", " + replace_all_distinct(pluginopts, ";", ", ");
break;