From 66dde82c855a43fed390104da918ddb3652fd46b Mon Sep 17 00:00:00 2001 From: Tindy X <49061470+tindy2013@users.noreply.github.com> Date: Thu, 16 Jan 2020 21:50:27 +0800 Subject: [PATCH] Fix bugs Fix when no custom ruleset is set in external config file, no rules will be generated. Fix ws-path parsing for Quantumult X VMess subscription. Add README for Docker. Optimize codes. --- README-docker.md | 19 +++++++++++++++++++ src/main.cpp | 8 +++++++- src/speedtestutil.cpp | 2 ++ src/subexport.cpp | 2 ++ 4 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 README-docker.md diff --git a/README-docker.md b/README-docker.md new file mode 100644 index 0000000..c636309 --- /dev/null +++ b/README-docker.md @@ -0,0 +1,19 @@ +# subconverter-docker +------ +This is a minimized image to run https://github.com/tindy2013/subconverter. + +For running this docker, simply use the following commands: +```bash +# run the container detached, forward internal port 25500 to host port 25500 +docker run -d -p 25500:25500 tindy2013/subconverter:latest +# then check its status +curl http://localhost:25500 +# if you see `subconverter vx.x.x backend` then the container is up and running +``` + +If you want to update `pref.ini` inside the docker, you can use the following command: +```bash +# assume your configuration file name is `newpref.ini` +curl -F "@data=newpref.ini" http://localhost:25500/updateconf?type=form&token=password +# you may want to change this token in your configuration file +``` diff --git a/src/main.cpp b/src/main.cpp index 0a70525..e654d60 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -268,7 +268,7 @@ struct ExternalConfig std::string surge_rule_base; std::string surfboard_rule_base; std::string mellow_rule_base; - bool overwrite_original_rules = true; + bool overwrite_original_rules = false; bool enable_rule_generator = true; }; @@ -408,6 +408,12 @@ std::string subconverter(RESPONSE_CALLBACK_ARGS) extra_ruleset = extconf.surge_ruleset; refreshRulesets(extra_ruleset, rca); } + else + { + if(update_ruleset_on_request || cfw_child_process) + refreshRulesets(rulesets, ruleset_content_array); + rca = ruleset_content_array; + } } else { diff --git a/src/speedtestutil.cpp b/src/speedtestutil.cpp index b27fc1e..724b4cb 100644 --- a/src/speedtestutil.cpp +++ b/src/speedtestutil.cpp @@ -1366,6 +1366,8 @@ bool explodeSurge(std::string surge, std::string custom_port, int local_port, st } else if(itemName == "obfs-host") host = itemVal; + else if(itemName == "obfs-uri") + path = itemVal; else if(itemName == "over-tls") tls = itemVal == "true" ? "tls" : ""; } diff --git a/src/subexport.cpp b/src/subexport.cpp index 77ca34c..087a143 100644 --- a/src/subexport.cpp +++ b/src/subexport.cpp @@ -67,6 +67,8 @@ std::string vmessConstruct(std::string add, std::string port, std::string type, path = "/"; if(!host.size()) host = add; + if(!id.size()) + id = "00000000-0000-0000-0000-000000000000"; //fill this field for node with empty id rapidjson::StringBuffer sb; rapidjson::Writer writer(sb); writer.StartObject();