From 31c638a779ab0bd6100863063e0a318adf300708 Mon Sep 17 00:00:00 2001 From: Tindy X <49061470+tindy2013@users.noreply.github.com> Date: Wed, 18 Dec 2019 15:30:00 +0800 Subject: [PATCH] Enhancements Add support for exporting Clash proxy-provider. Add version info on Web server main page. Fix program crash when no nodes are available in generating Mellow configuration. --- main.cpp | 5 +++++ subexport.cpp | 14 +++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/main.cpp b/main.cpp index b1dbc2a..3d7f1f4 100644 --- a/main.cpp +++ b/main.cpp @@ -494,6 +494,11 @@ int main(int argc, char *argv[]) if(!update_ruleset_on_request) refreshRulesets(rulesets, ruleset_content_array); + append_response("GET", "/", "text/plain", [](RESPONSE_CALLBACK_ARGS) -> std::string + { + return std::string("subconverter " VERSION " backend"); + }); + append_response("GET", "/refreshrules", "text/plain", [](RESPONSE_CALLBACK_ARGS) -> std::string { return refreshRulesets(rulesets, ruleset_content_array); diff --git a/subexport.cpp b/subexport.cpp index 8f6765c..6f4302b 100644 --- a/subexport.cpp +++ b/subexport.cpp @@ -552,6 +552,13 @@ std::string netchToClash(std::vector &nodes, std::string &base_conf, s nodelist.emplace_back(x); } + if(ext.nodelist) + { + YAML::Node provider; + provider["proxies"] = proxies; + return YAML::Dump(provider); + } + yamlnode["Proxy"] = proxies; std::string groupname; @@ -1504,7 +1511,12 @@ std::string netchToMellow(std::vector &nodes, std::string &base_conf, } if(!filtered_nodelist.size()) - filtered_nodelist = remarks_list; + { + if(!remarks_list.size()) + filtered_nodelist.emplace_back("DIRECT"); + else + filtered_nodelist = remarks_list; + } //don't process these for now /*