mirror of
https://github.com/asdlokj1qpi233/subconverter.git
synced 2026-11-04 02:34:06 +00:00
Fix inconsistency SS plugin name
Clean up codes.
This commit is contained in:
2 files changed
+35
-28
No files matched your search
@@ -75,21 +75,21 @@ void nodeRename(Proxy &node, const string_array &rename_array, extra_settings &e
|
|||||||
{
|
{
|
||||||
script_safe_runner(ext.js_runtime, ext.js_context, [&](qjs::Context &ctx)
|
script_safe_runner(ext.js_runtime, ext.js_context, [&](qjs::Context &ctx)
|
||||||
{
|
{
|
||||||
std::string script = x.substr(9);
|
std::string script = x.substr(9);
|
||||||
if(startsWith(script, "path:"))
|
if(startsWith(script, "path:"))
|
||||||
script = fileGet(script.substr(5), true);
|
script = fileGet(script.substr(5), true);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ctx.eval(script);
|
ctx.eval(script);
|
||||||
auto rename = (std::function<std::string(const Proxy&)>) ctx.eval("rename");
|
auto rename = (std::function<std::string(const Proxy&)>) ctx.eval("rename");
|
||||||
returned_remark = rename(node);
|
returned_remark = rename(node);
|
||||||
if(!returned_remark.empty())
|
if(!returned_remark.empty())
|
||||||
remark = returned_remark;
|
remark = returned_remark;
|
||||||
}
|
}
|
||||||
catch (qjs::exception)
|
catch (qjs::exception)
|
||||||
{
|
{
|
||||||
script_print_stack(ctx);
|
script_print_stack(ctx);
|
||||||
}
|
}
|
||||||
}, gScriptCleanContext);
|
}, gScriptCleanContext);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -263,18 +263,25 @@ void preprocessNodes(std::vector<Proxy> &nodes, extra_settings &ext)
|
|||||||
script = fileGet(script.substr(5), false);
|
script = fileGet(script.substr(5), false);
|
||||||
script_safe_runner(ext.js_runtime, ext.js_context, [&](qjs::Context &ctx)
|
script_safe_runner(ext.js_runtime, ext.js_context, [&](qjs::Context &ctx)
|
||||||
{
|
{
|
||||||
ctx.eval(script);
|
try
|
||||||
auto compare = (std::function<int(const Proxy&, const Proxy&)>) ctx.eval("compare");
|
|
||||||
auto comparer = [&](const Proxy &a, const Proxy &b)
|
|
||||||
{
|
{
|
||||||
if(a.Type == ProxyType::Unknow)
|
ctx.eval(script);
|
||||||
return 1;
|
auto compare = (std::function<int(const Proxy&, const Proxy&)>) ctx.eval("compare");
|
||||||
if(b.Type == ProxyType::Unknow)
|
auto comparer = [&](const Proxy &a, const Proxy &b)
|
||||||
return 0;
|
{
|
||||||
return compare(a, b);
|
if(a.Type == ProxyType::Unknow)
|
||||||
};
|
return 1;
|
||||||
std::stable_sort(nodes.begin(), nodes.end(), comparer);
|
if(b.Type == ProxyType::Unknow)
|
||||||
failed = false;
|
return 0;
|
||||||
|
return compare(a, b);
|
||||||
|
};
|
||||||
|
std::stable_sort(nodes.begin(), nodes.end(), comparer);
|
||||||
|
failed = false;
|
||||||
|
}
|
||||||
|
catch(qjs::exception)
|
||||||
|
{
|
||||||
|
script_print_stack(ctx);
|
||||||
|
}
|
||||||
}, gScriptCleanContext);
|
}, gScriptCleanContext);
|
||||||
}
|
}
|
||||||
if(failed) std::stable_sort(nodes.begin(), nodes.end(), [](const Proxy &a, const Proxy &b)
|
if(failed) std::stable_sort(nodes.begin(), nodes.end(), [](const Proxy &a, const Proxy &b)
|
||||||
@@ -1164,7 +1171,7 @@ void proxyToQuan(std::vector<Proxy> &nodes, INIReader &ini, std::vector<ruleset_
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
proxyStr = remark + " = shadowsocks, " + hostname + ", " + port + ", " + method + ", \"" + password + "\", group=" + x.Group;
|
proxyStr = remark + " = shadowsocks, " + hostname + ", " + port + ", " + method + ", \"" + password + "\", group=" + x.Group;
|
||||||
if(plugin == "simple-obfs" && pluginopts.size())
|
if(plugin == "obfs-local" && pluginopts.size())
|
||||||
{
|
{
|
||||||
proxyStr += ", " + replaceAllDistinct(pluginopts, ";", ", ");
|
proxyStr += ", " + replaceAllDistinct(pluginopts, ";", ", ");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1010,7 +1010,7 @@ void explodeClash(Node yamlnode, std::vector<Proxy> &nodes)
|
|||||||
}
|
}
|
||||||
else if(singleproxy["obfs"].IsDefined())
|
else if(singleproxy["obfs"].IsDefined())
|
||||||
{
|
{
|
||||||
plugin = "simple-obfs";
|
plugin = "obfs-local";
|
||||||
singleproxy["obfs"] >>= pluginopts_mode;
|
singleproxy["obfs"] >>= pluginopts_mode;
|
||||||
singleproxy["obfs-host"] >>= pluginopts_host;
|
singleproxy["obfs-host"] >>= pluginopts_host;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user