From 7968d544763a22cf1853e85d5d0d748a9c460040 Mon Sep 17 00:00:00 2001 From: Tindy X <49061470+tindy2013@users.noreply.github.com> Date: Sun, 19 Nov 2023 18:29:04 +0800 Subject: [PATCH] Treat "simple-obfs" in sing-box configs as obfs-local --- src/generator/config/subexport.cpp | 2 ++ src/script/script_quickjs.cpp | 2 +- src/script/script_quickjs.h | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/generator/config/subexport.cpp b/src/generator/config/subexport.cpp index 499eadf..3e43631 100644 --- a/src/generator/config/subexport.cpp +++ b/src/generator/config/subexport.cpp @@ -2140,6 +2140,8 @@ void proxyToSingBox(std::vector &nodes, rapidjson::Document &json, std::v proxy.AddMember("password", rapidjson::StringRef(x.Password.c_str()), allocator); if(!x.Plugin.empty() && !x.PluginOption.empty()) { + if (x.Plugin == "simple-obfs") + x.Plugin = "obfs-local"; proxy.AddMember("plugin", rapidjson::StringRef(x.Plugin.c_str()), allocator); proxy.AddMember("plugin_opts", rapidjson::StringRef(x.PluginOption.c_str()), allocator); } diff --git a/src/script/script_quickjs.cpp b/src/script/script_quickjs.cpp index bd798ea..d7d0195 100644 --- a/src/script/script_quickjs.cpp +++ b/src/script/script_quickjs.cpp @@ -255,7 +255,7 @@ namespace qjs string_icase_map res; JSPropertyEnum *props = nullptr, *props_begin; uint32_t len = 0; - JS_GetOwnPropertyNames(ctx, &props, &len, v, 1); + JS_GetOwnPropertyNames(ctx, &props, &len, v, JS_GPN_STRING_MASK | JS_GPN_ENUM_ONLY); props_begin = props; while(len > 0) { diff --git a/src/script/script_quickjs.h b/src/script/script_quickjs.h index ff89f1b..c370226 100644 --- a/src/script/script_quickjs.h +++ b/src/script/script_quickjs.h @@ -68,7 +68,7 @@ namespace qjs { static StringArray unwrap(JSContext *ctx, JSValueConst v) { StringArray arr; - uint32_t length = unwrap_free(ctx, v, "length"); + auto length = unwrap_free(ctx, v, "length"); for (uint32_t i = 0; i < length; i++) { arr.push_back(JS_GetPropertyIndexToString(ctx, v, i)); }