Skip to content

Commit

Permalink
Fix inconsistency SS plugin name
Browse files Browse the repository at this point in the history
Clean up codes.
  • Loading branch information
tindy2013 committed Jul 28, 2021
1 parent 5f5615d commit 3ad1c00
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 28 deletions.
61 changes: 34 additions & 27 deletions src/generator/config/subexport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
std::string script = x.substr(9);
if(startsWith(script, "path:"))
script = fileGet(script.substr(5), true);
try
{
ctx.eval(script);
auto rename = (std::function<std::string(const Proxy&)>) ctx.eval("rename");
returned_remark = rename(node);
if(!returned_remark.empty())
remark = returned_remark;
}
catch (qjs::exception)
{
script_print_stack(ctx);
}
std::string script = x.substr(9);
if(startsWith(script, "path:"))
script = fileGet(script.substr(5), true);
try
{
ctx.eval(script);
auto rename = (std::function<std::string(const Proxy&)>) ctx.eval("rename");
returned_remark = rename(node);
if(!returned_remark.empty())
remark = returned_remark;
}
catch (qjs::exception)
{
script_print_stack(ctx);
}
}, gScriptCleanContext);
continue;
}
Expand Down Expand Up @@ -263,18 +263,25 @@ void preprocessNodes(std::vector<Proxy> &nodes, extra_settings &ext)
script = fileGet(script.substr(5), false);
script_safe_runner(ext.js_runtime, ext.js_context, [&](qjs::Context &ctx)
{
ctx.eval(script);
auto compare = (std::function<int(const Proxy&, const Proxy&)>) ctx.eval("compare");
auto comparer = [&](const Proxy &a, const Proxy &b)
try
{
if(a.Type == ProxyType::Unknow)
return 1;
if(b.Type == ProxyType::Unknow)
return 0;
return compare(a, b);
};
std::stable_sort(nodes.begin(), nodes.end(), comparer);
failed = false;
ctx.eval(script);
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)
return 1;
if(b.Type == ProxyType::Unknow)
return 0;
return compare(a, b);
};
std::stable_sort(nodes.begin(), nodes.end(), comparer);
failed = false;
}
catch(qjs::exception)
{
script_print_stack(ctx);
}
}, gScriptCleanContext);
}
if(failed) std::stable_sort(nodes.begin(), nodes.end(), [](const Proxy &a, const Proxy &b)
Expand Down Expand Up @@ -1164,7 +1171,7 @@ void proxyToQuan(std::vector<Proxy> &nodes, INIReader &ini, std::vector<ruleset_
else
{
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, ";", ", ");
}
Expand Down
2 changes: 1 addition & 1 deletion src/parser/subparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1010,7 +1010,7 @@ void explodeClash(Node yamlnode, std::vector<Proxy> &nodes)
}
else if(singleproxy["obfs"].IsDefined())
{
plugin = "simple-obfs";
plugin = "obfs-local";
singleproxy["obfs"] >>= pluginopts_mode;
singleproxy["obfs-host"] >>= pluginopts_host;
}
Expand Down

0 comments on commit 3ad1c00

Please sign in to comment.