diff --git a/luci-app-openclash/luasrc/model/cbi/openclash/proxy-provider-config.lua b/luci-app-openclash/luasrc/model/cbi/openclash/proxy-provider-config.lua index 502f269f1e..943aef5e0a 100644 --- a/luci-app-openclash/luasrc/model/cbi/openclash/proxy-provider-config.lua +++ b/luci-app-openclash/luasrc/model/cbi/openclash/proxy-provider-config.lua @@ -59,6 +59,7 @@ o.rmempty = true o.description = translate("Choose The Provider Type") o:value("http") o:value("file") +o:value("inline") o = s:option(Value, "name", translate("Provider Name")) o.rmempty = false @@ -134,7 +135,16 @@ function o.cfgvalue(self, section) "# proxy-name:\n".. "# - pattern: \"IPLC-(.*?)倍\"\n".. "# target: \"iplc x $1\"\n".. - "# exclude-type: \"ss|http\"" + "# exclude-type: \"ss|http\"\n".. + "\n".. + "# inline Example:\n".. + "# payload:\n".. + "# - name: \"ss1\"\n".. + "# type: ss\n".. + "# server: server\n".. + "# port: 443\n".. + "# cipher: chacha20-ietf-poly1305\n".. + "# password: \"password\"" else return Value.cfgvalue(self, section) end diff --git a/luci-app-openclash/luasrc/model/cbi/openclash/rule-providers-config.lua b/luci-app-openclash/luasrc/model/cbi/openclash/rule-providers-config.lua index e8ccb70265..2a77a5cf6f 100644 --- a/luci-app-openclash/luasrc/model/cbi/openclash/rule-providers-config.lua +++ b/luci-app-openclash/luasrc/model/cbi/openclash/rule-providers-config.lua @@ -57,15 +57,9 @@ o.default = "Rule-provider - "..sid o = s:option(ListValue, "type", translate("Rule Providers Type")) o.rmempty = true o.description = translate("Choose The Rule Providers Type") -o:value("http", translate("http")) -o:value("file", translate("file")) - -o = s:option(ListValue, "behavior", translate("Rule Behavior")) -o.rmempty = true -o.description = translate("Choose The Rule Behavior") -o:value("domain") -o:value("ipcidr") -o:value("classical") +o:value("http") +o:value("file") +o:value("inline") o = s:option(ListValue, "format", translate("Rule Format")..translate("(TUN&Meta Core)")) o.rmempty = true @@ -73,6 +67,15 @@ o.description = translate("Choose The Rule File Format, For More Info:").." ".." o:value("yaml") o:value("text") o:value("mrs") +o:depends("type", "file") +o:depends("type", "http") + +o = s:option(ListValue, "behavior", translate("Rule Behavior")) +o.rmempty = true +o.description = translate("Choose The Rule Behavior") +o:value("domain") +o:value("ipcidr") +o:value("classical", translate("classical").." "..translate("(Not Support mrs Format)")) o = s:option(ListValue, "path", translate("Rule Providers Path")) o.description = translate("Update Your Rule Providers File From Config Luci Page") @@ -136,6 +139,36 @@ m.uci:foreach("openclash", "groups", o:value("DIRECT") o:value("REJECT") +-- [[ other-setting ]]-- +o = s:option(Value, "other_parameters", translate("Other Parameters")) +o.template = "cbi/tvalue" +o.rows = 20 +o.wrap = "off" +o.description = font_red..bold_on..translate("Edit Your Other Parameters Here")..bold_off..font_off +o.rmempty = true +function o.cfgvalue(self, section) + if self.map:get(section, "other_parameters") == nil then + return "# Example:\n".. + "# Only support YAML, four spaces need to be reserved at the beginning of each line to maintain formatting alignment\n".. + "# 示例:\n".. + "# 仅支持 YAML, 每行行首需要多保留四个空格以使脚本处理后能够与上方配置保持格式对齐\n".. + "# inline Example:\n".. + "# payload:\n".. + "# - '.blogger.com'\n".. + "# - '*.*.microsoft.com'\n".. + "# - 'books.itunes.apple.com'\n" + else + return Value.cfgvalue(self, section) + end +end +function o.validate(self, value) + if value then + value = value:gsub("\r\n?", "\n") + value = value:gsub("%c*$", "") + end + return value +end + local t = { {Commit, Back} } @@ -159,4 +192,5 @@ o.write = function() end m:append(Template("openclash/toolbar_show")) +m:append(Template("openclash/config_editor")) return m diff --git a/luci-app-openclash/po/zh-cn/openclash.zh-cn.po b/luci-app-openclash/po/zh-cn/openclash.zh-cn.po index 72255cc471..45b3923232 100644 --- a/luci-app-openclash/po/zh-cn/openclash.zh-cn.po +++ b/luci-app-openclash/po/zh-cn/openclash.zh-cn.po @@ -3451,4 +3451,7 @@ msgid "Target" msgstr "对象" msgid "Error: Network Anomaly, Suspend Unlock Detection..." -msgstr "错误:网络异常,暂停解锁检测..." \ No newline at end of file +msgstr "错误:网络异常,暂停解锁检测..." + +msgid "(Not Support mrs Format)" +msgstr "(不支持 mrs 格式)" \ No newline at end of file diff --git a/luci-app-openclash/root/usr/share/openclash/yml_rules_change.sh b/luci-app-openclash/root/usr/share/openclash/yml_rules_change.sh index e498e16088..47df0c23e0 100644 --- a/luci-app-openclash/root/usr/share/openclash/yml_rules_change.sh +++ b/luci-app-openclash/root/usr/share/openclash/yml_rules_change.sh @@ -18,7 +18,7 @@ SKIP_CUSTOM_OTHER_RULES=0 yml_set_custom_rule_provider() { local section="$1" - local enabled name config type behavior path url interval group position + local enabled name config type behavior path url interval group position other_parameters config_get_bool "enabled" "$section" "enabled" "1" config_get "name" "$section" "name" "" config_get "config" "$section" "config" "" @@ -30,6 +30,7 @@ yml_set_custom_rule_provider() config_get "group" "$section" "group" "" config_get "position" "$section" "position" "" config_get "format" "$section" "format" "" + config_get "other_parameters" "$section" "other_parameters" "" if [ "$enabled" = "0" ]; then return @@ -63,7 +64,7 @@ yml_set_custom_rule_provider() else path="./rule_provider/$name.yaml" fi - elif [ -z "$path" ]; then + elif [ -z "$path" ] && [ "$type" != "inline" ]; then return fi @@ -79,8 +80,12 @@ cat >> "$RULE_PROVIDER_FILE" <<-EOF $name: type: $type behavior: $behavior +EOF + if [ -n "$path" ]; then +cat >> "$RULE_PROVIDER_FILE" <<-EOF path: $path EOF + fi if [ -n "$format" ]; then cat >> "$RULE_PROVIDER_FILE" <<-EOF format: $format @@ -93,6 +98,11 @@ cat >> "$RULE_PROVIDER_FILE" <<-EOF EOF fi + #other_parameters + if [ -n "$other_parameters" ]; then + echo -e "$other_parameters" >> "$RULE_PROVIDER_FILE" + fi + yml_rule_set_add "$name" "$group" "$position" }