From b384325f2e6447e778c1a745f1f61cc2e4f222a1 Mon Sep 17 00:00:00 2001 From: zxlhhyccc <45259624+zxlhhyccc@users.noreply.github.com> Date: Sun, 10 Mar 2024 16:50:40 +0800 Subject: [PATCH 01/36] add Port Hopping (#3792) * add Port Hopping The latest version of meta supports port hopping for hy2 https://github.com/MetaCubeX/mihomo/commit/feedc9ec66b8afca3c76c82202cf9b7d69af3e75 --- .../model/cbi/openclash/servers-config.lua | 50 +++++++++++++++---- .../po/zh-cn/openclash.zh-cn.po | 11 +++- .../usr/share/openclash/yml_proxys_get.sh | 34 ++++++++++++- .../usr/share/openclash/yml_proxys_set.sh | 16 ++++++ 4 files changed, 97 insertions(+), 14 deletions(-) diff --git a/luci-app-openclash/luasrc/model/cbi/openclash/servers-config.lua b/luci-app-openclash/luasrc/model/cbi/openclash/servers-config.lua index 47e930fb89..30f58836af 100644 --- a/luci-app-openclash/luasrc/model/cbi/openclash/servers-config.lua +++ b/luci-app-openclash/luasrc/model/cbi/openclash/servers-config.lua @@ -81,6 +81,10 @@ local hysteria_protocols = { "faketcp" } +local hysteria2_protocols = { + "udp" +} + local obfs = { "plain", "http_simple", @@ -157,12 +161,19 @@ o.datatype = "port" o.rmempty = false o.default = "443" +o = s:option(Flag, "flag_port_hopping", translate("Enable Port Hopping")) +o:depends("type", "hysteria") +o:depends("type", "hysteria2") +o.rmempty = true +o.default = "0" + o = s:option(Value, "ports", translate("Port Hopping")) o.datatype = "portrange" o.rmempty = true o.default = "20000-40000" o.placeholder = translate("20000-40000") -o:depends("type", "hysteria") +o:depends({type = "hysteria", flag_port_hopping = true}) +o:depends({type = "hysteria2", flag_port_hopping = true}) o = s:option(Value, "password", translate("Password")) o.password = true @@ -278,10 +289,21 @@ o.default = "1420" o.placeholder = translate("1420") o:depends("type", "wireguard") +o = s:option(Flag, "flag_transport", translate("Enable Transport Protocol Settings")) +o:depends("type", "hysteria") +o:depends("type", "hysteria2") +o.rmempty = true +o.default = "0" + o = s:option(ListValue, "hysteria_protocol", translate("Protocol")) for _, v in ipairs(hysteria_protocols) do o:value(v) end o.rmempty = false -o:depends("type", "hysteria") +o:depends({type = "hysteria", flag_transport = true}) + +o = s:option(ListValue, "hysteria2_protocol", translate("Protocol")) +for _, v in ipairs(hysteria2_protocols) do o:value(v) end +o.rmempty = false +o:depends({type = "hysteria2", flag_transport = true}) o = s:option(Value, "hysteria_up", translate("up")) o.rmempty = false @@ -682,18 +704,30 @@ o:depends("type", "hysteria") o:depends("type", "hysteria2") -- [[ recv_window_conn ]]-- +o = s:option(Flag, "flag_quicparam", translate("Hysterir QUIC parameters")) +o:depends("type", "hysteria") +o.rmempty = true +o.default = "0" + o = s:option(Value, "recv_window_conn", translate("recv_window_conn")) o.rmempty = true o.placeholder = translate("QUIC stream receive window") o.datatype = "uinteger" -o:depends("type", "hysteria") +o:depends({type = "hysteria", flag_quicparam = true}) -- [[ recv_window ]]-- o = s:option(Value, "recv_window", translate("recv_window")) o.rmempty = true o.placeholder = translate("QUIC connection receive window") o.datatype = "uinteger" -o:depends("type", "hysteria") +o:depends({type = "hysteria", flag_quicparam = true}) + +-- [[ hop_interval ]]-- +o = s:option(Value, "hop_interval", translate("Hop Interval")) +o.rmempty = true +o.default = "10" +o:depends({type = "hysteria", flag_transport = true, flag_port_hopping = true}) +o:depends({type = "hysteria2", flag_port_hopping = true}) -- [[ disable_mtu_discovery ]]-- o = s:option(ListValue, "disable_mtu_discovery", translate("disable_mtu_discovery")) @@ -701,13 +735,7 @@ o.rmempty = true o:value("true") o:value("false") o.default = "false" -o:depends("type", "hysteria") - --- [[ hop_interval ]]-- -o = s:option(Value, "hop_interval", translate("Hop Interval")) -o.rmempty = true -o.default = "10" -o:depends("type", "hysteria") +o:depends({type = "hysteria", flag_quicparam = true}) o = s:option(ListValue, "packet-addr", translate("Packet-Addr")..translate("(Only Meta Core)")) o.rmempty = true 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 44a68bd864..9d0f7a6848 100644 --- a/luci-app-openclash/po/zh-cn/openclash.zh-cn.po +++ b/luci-app-openclash/po/zh-cn/openclash.zh-cn.po @@ -765,6 +765,15 @@ msgstr "策略组配置(使用一键生成配置文件功能时无需设置) msgid "Proxies" msgstr "服务器节点配置" +msgid "Enable Port Hopping" +msgstr "启用端口跃迁" + +msgid "Enable Transport Protocol Settings" +msgstr "启用传输协议设置" + +msgid "Hysterir QUIC parameters" +msgstr "QUIC 参数" + msgid "Edit Rule Providers" msgstr "编辑规则集配置" @@ -3496,4 +3505,4 @@ msgid "Skip Proxy Address" msgstr "绕过服务器地址" msgid "Bypassing Server Addresses And Preventing Duplicate Proxies" -msgstr "绕过服务器地址,防止重复代理" \ No newline at end of file +msgstr "绕过服务器地址,防止重复代理" diff --git a/luci-app-openclash/root/usr/share/openclash/yml_proxys_get.sh b/luci-app-openclash/root/usr/share/openclash/yml_proxys_get.sh index 0cfe1a8b53..74feb279c8 100644 --- a/luci-app-openclash/root/usr/share/openclash/yml_proxys_get.sh +++ b/luci-app-openclash/root/usr/share/openclash/yml_proxys_get.sh @@ -1027,7 +1027,8 @@ do }.join end; - if '$server_type' == 'hysteria' or '$server_type' == 'hysteria2' then + if '$server_type' == 'hysteria' then + #hysteria Thread.new{ #hysteria_protocol if Value['proxies'][$count].key?('protocol') then @@ -1036,6 +1037,18 @@ do end }.join + if '$server_type' == 'hysteria2' then + #hysteria2 + Thread.new{ + #hysteria2_protocol + if Value['proxies'][$count].key?('protocol') then + hysteria2_protocol = '${uci_set}hysteria2_protocol=\"' + Value['proxies'][$count]['protocol'].to_s + '\"' + system(hysteria2_protocol) + end + }.join + + if '$server_type' == 'hysteria' or '$server_type' == 'hysteria2' then + #hysteria hysteria2 Thread.new{ #hysteria_up if Value['proxies'][$count].key?('up') then @@ -1044,6 +1057,7 @@ do end }.join + #hysteria hysteria2 Thread.new{ #hysteria_down if Value['proxies'][$count].key?('down') then @@ -1052,6 +1066,7 @@ do end }.join + #hysteria hysteria2 Thread.new{ #skip-cert-verify if Value['proxies'][$count].key?('skip-cert-verify') then @@ -1060,6 +1075,7 @@ do end }.join + #hysteria hysteria2 Thread.new{ #sni if Value['proxies'][$count].key?('sni') then @@ -1068,6 +1084,7 @@ do end }.join + #hysteria hysteria2 Thread.new{ #alpn if Value['proxies'][$count].key?('alpn') then @@ -1085,6 +1102,7 @@ do end; }.join + #hysteria Thread.new{ #recv_window_conn if Value['proxies'][$count].key?('recv-window-conn') then @@ -1093,6 +1111,7 @@ do end }.join + #hysteria Thread.new{ #recv_window if Value['proxies'][$count].key?('recv-window') then @@ -1101,6 +1120,7 @@ do end }.join + #hysteria hysteria2 Thread.new{ #hysteria_obfs if Value['proxies'][$count].key?('obfs') then @@ -1109,6 +1129,7 @@ do end }.join + #hysteria hysteria2 Thread.new{ #hysteria_obfs_password if Value['proxies'][$count].key?('obfs-password') then @@ -1117,6 +1138,7 @@ do end }.join + #hysteria Thread.new{ #hysteria_auth if Value['proxies'][$count].key?('auth') then @@ -1125,6 +1147,7 @@ do end }.join + #hysteria Thread.new{ #hysteria_auth_str if Value['proxies'][$count].key?('auth-str') then @@ -1133,6 +1156,7 @@ do end }.join + #hysteria hysteria2 Thread.new{ #hysteria_ca if Value['proxies'][$count].key?('ca') then @@ -1141,6 +1165,7 @@ do end }.join + #hysteria hysteria2 Thread.new{ #hysteria_ca_str if Value['proxies'][$count].key?('ca-str') then @@ -1149,6 +1174,7 @@ do end }.join + #hysteria Thread.new{ #disable_mtu_discovery if Value['proxies'][$count].key?('disable-mtu-discovery') then @@ -1157,6 +1183,7 @@ do end }.join + #hysteria Thread.new{ #fast_open if Value['proxies'][$count].key?('fast-open') then @@ -1165,6 +1192,7 @@ do end }.join + #hysteria hysteria2 Thread.new{ #fingerprint if Value['proxies'][$count].key?('fingerprint') then @@ -1173,6 +1201,7 @@ do end }.join + #hysteria hysteria2 Thread.new{ #ports if Value['proxies'][$count].key?('ports') then @@ -1181,6 +1210,7 @@ do end }.join + #hysteria hysteria2 Thread.new{ #hop-interval if Value['proxies'][$count].key?('hop-interval') then @@ -1573,4 +1603,4 @@ SLOG_CLEAN rm -rf /tmp/match_servers.list 2>/dev/null rm -rf /tmp/match_provider.list 2>/dev/null rm -rf /tmp/yaml_other_group.yaml 2>/dev/null -del_lock \ No newline at end of file +del_lock diff --git a/luci-app-openclash/root/usr/share/openclash/yml_proxys_set.sh b/luci-app-openclash/root/usr/share/openclash/yml_proxys_set.sh index 2da4b1c9e4..149cdce7f1 100644 --- a/luci-app-openclash/root/usr/share/openclash/yml_proxys_set.sh +++ b/luci-app-openclash/root/usr/share/openclash/yml_proxys_set.sh @@ -246,6 +246,7 @@ yml_servers_set() config_get "vless_flow" "$section" "vless_flow" "" config_get "http_headers" "$section" "http_headers" "" config_get "hysteria_protocol" "$section" "hysteria_protocol" "" + config_get "hysteria2_protocol" "$section" "hysteria2_protocol" "" config_get "hysteria_up" "$section" "hysteria_up" "" config_get "hysteria_down" "$section" "hysteria_down" "" config_get "hysteria_alpn" "$section" "hysteria_alpn" "" @@ -977,6 +978,21 @@ EOF if [ -n "$fingerprint" ]; then cat >> "$SERVER_FILE" <<-EOF fingerprint: "$fingerprint" +EOF + fi + if [ -n "$ports" ]; then +cat >> "$SERVER_FILE" <<-EOF + ports: $ports +EOF + fi + if [ -n "$hysteria2_protocol" ]; then +cat >> "$SERVER_FILE" <<-EOF + protocol: $hysteria2_protocol +EOF + fi + if [ -n "$hop_interval" ]; then +cat >> "$SERVER_FILE" <<-EOF + hop-interval: $hop_interval EOF fi fi From b12c01672396ea3961c791366aa8797103f07f6b Mon Sep 17 00:00:00 2001 From: zxlhhyccc <45259624+zxlhhyccc@users.noreply.github.com> Date: Mon, 11 Mar 2024 14:06:36 +0800 Subject: [PATCH 02/36] Fix the protocol that exists in the configuration file when the protocol is not configured. (#3794) There are bugs in the original code --- .../luasrc/model/cbi/openclash/servers-config.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/luci-app-openclash/luasrc/model/cbi/openclash/servers-config.lua b/luci-app-openclash/luasrc/model/cbi/openclash/servers-config.lua index 30f58836af..62145aad45 100644 --- a/luci-app-openclash/luasrc/model/cbi/openclash/servers-config.lua +++ b/luci-app-openclash/luasrc/model/cbi/openclash/servers-config.lua @@ -297,12 +297,12 @@ o.default = "0" o = s:option(ListValue, "hysteria_protocol", translate("Protocol")) for _, v in ipairs(hysteria_protocols) do o:value(v) end -o.rmempty = false +o.rmempty = true o:depends({type = "hysteria", flag_transport = true}) o = s:option(ListValue, "hysteria2_protocol", translate("Protocol")) for _, v in ipairs(hysteria2_protocols) do o:value(v) end -o.rmempty = false +o.rmempty = true o:depends({type = "hysteria2", flag_transport = true}) o = s:option(Value, "hysteria_up", translate("up")) From fa1cc40fd79904707857bcef722b727d9f88b046 Mon Sep 17 00:00:00 2001 From: snachx Date: Thu, 14 Mar 2024 01:36:46 +0800 Subject: [PATCH 03/36] IPv6 support for dns debugging and skip proxy address feature (#3801) Skip Proxy Address feature relies on the openclash_debug_dns.lua script. This update has added IPv6 support, enabling the Skip Proxy Address functionality to also support IPv6. --- .../share/openclash/openclash_debug_dns.lua | 104 +++++++++--------- 1 file changed, 55 insertions(+), 49 deletions(-) diff --git a/luci-app-openclash/root/usr/share/openclash/openclash_debug_dns.lua b/luci-app-openclash/root/usr/share/openclash/openclash_debug_dns.lua index b567fb6450..59064af318 100644 --- a/luci-app-openclash/root/usr/share/openclash/openclash_debug_dns.lua +++ b/luci-app-openclash/root/usr/share/openclash/openclash_debug_dns.lua @@ -22,61 +22,67 @@ local function debug_dns() local passwd = uci:get("openclash", "config", "dashboard_password") or "" if datatype.hostname(addr) and ip and port then - info = luci.sys.exec(string.format('curl -sL -m 3 -H "Content-Type: application/json" -H "Authorization: Bearer %s" -XGET http://"%s":"%s"/dns/query?name="%s"', passwd, ip, port, addr)) - if info then - info = json.parse(info) + info_v4 = luci.sys.exec(string.format('curl -sL -m 3 -H "Content-Type: application/json" -H "Authorization: Bearer %s" -XGET http://"%s":"%s"/dns/query?name="%s"', passwd, ip, port, addr)) + info_v6 = luci.sys.exec(string.format('curl -sL -m 3 -H "Content-Type: application/json" -H "Authorization: Bearer %s" -XGET \"http://"%s":"%s"/dns/query?name="%s"&type=AAAA\"', passwd, ip, port, addr)) + if info_v4 then + info_v4 = json.parse(info_v4) end - if info and not resolve then - print("Status: "..(info.Status)) - print("TC: "..tostring(info.TC)) - print("RD: "..tostring(info.RD)) - print("RA: "..tostring(info.RA)) - print("AD: "..tostring(info.AD)) - print("CD: "..tostring(info.CD)) - print("") - print("Question: ") - for _, v in pairs(info.Question) do - print(" Name: "..(v.Name)) - print(" Qtype: "..(v.Qtype)) - print(" Qclass: "..(v.Qclass)) + if info_v6 then + info_v6 = json.parse(info_v6) + end + for _, info in pairs({info_v4, info_v6}) do + if info and not resolve then + print("Status: "..(info.Status)) + print("TC: "..tostring(info.TC)) + print("RD: "..tostring(info.RD)) + print("RA: "..tostring(info.RA)) + print("AD: "..tostring(info.AD)) + print("CD: "..tostring(info.CD)) print("") - end - if info.Answer then - print("Answer: ") - for _, v in pairs(info.Answer) do - print(" TTL: "..(v.TTL)) - print(" data: "..(v.data:gsub("\n?", ""))) - print(" name: "..(v.name)) - print(" type: "..(v.type)) + print("Question: ") + for _, v in pairs(info.Question) do + print(" Name: "..(v.Name)) + print(" Qtype: "..(v.Qtype)) + print(" Qclass: "..(v.Qclass)) print("") end - end - if info.Additional then - print("Additional: ") - for _, v in pairs(info.Additional) do - print(" TTL: "..(v.TTL)) - print(" data: "..(v.data:gsub("\n?", ""))) - print(" name: "..(v.name)) - print(" type: "..(v.type)) - print("") + if info.Answer then + print("Answer: ") + for _, v in pairs(info.Answer) do + print(" TTL: "..(v.TTL)) + print(" data: "..(v.data:gsub("\n?", ""))) + print(" name: "..(v.name)) + print(" type: "..(v.type)) + print("") + end end - end - if info.Authority then - print("Authority: ") - for _, v in pairs(info.Authority) do - print(" TTL: "..(v.TTL)) - print(" data: "..(v.data:gsub("\n?", ""))) - print(" name: "..(v.name)) - print(" type: "..(v.type)) - print("") + if info.Additional then + print("Additional: ") + for _, v in pairs(info.Additional) do + print(" TTL: "..(v.TTL)) + print(" data: "..(v.data:gsub("\n?", ""))) + print(" name: "..(v.name)) + print(" type: "..(v.type)) + print("") + end + end + if info.Authority then + print("Authority: ") + for _, v in pairs(info.Authority) do + print(" TTL: "..(v.TTL)) + print(" data: "..(v.data:gsub("\n?", ""))) + print(" name: "..(v.name)) + print(" type: "..(v.type)) + print("") + end end end - end - if info and resolve then - if info.Answer then - for _, v in pairs(info.Answer) do - if v.type == 1 then - print(v.data) + if info and resolve then + if info.Answer then + for _, v in pairs(info.Answer) do + if v.type == 1 or v.type == 28 then + print(v.data) + end end end end @@ -85,4 +91,4 @@ local function debug_dns() os.exit(0) end -debug_dns() \ No newline at end of file +debug_dns() From f0c1cffa183cb5bffb4e65eeaee0ff02b287f87c Mon Sep 17 00:00:00 2001 From: bcseputetto Date: Fri, 15 Mar 2024 22:07:09 +0800 Subject: [PATCH 04/36] fix add_utun_firewall_zone (#3802) --- luci-app-openclash/root/etc/uci-defaults/luci-openclash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/luci-app-openclash/root/etc/uci-defaults/luci-openclash b/luci-app-openclash/root/etc/uci-defaults/luci-openclash index 98bf0d7b5c..a3f792fafd 100644 --- a/luci-app-openclash/root/etc/uci-defaults/luci-openclash +++ b/luci-app-openclash/root/etc/uci-defaults/luci-openclash @@ -204,7 +204,7 @@ add_utun_firewall_zone() config_get "name" "$section" "name" "" config_get "network" "$section" "network" "" if [ "$name" = "lan" ] && [ -z "$(echo $network |grep utun)" ]; then - uci -q set firewall."$section".network="$network utun" + uci -q add_list firewall."$section".network="utun" uci -q commit firewall fi } From a6784690ea0c29cf32b4c304881bc13b2df8c6e7 Mon Sep 17 00:00:00 2001 From: zxlhhyccc <45259624+zxlhhyccc@users.noreply.github.com> Date: Mon, 18 Mar 2024 22:10:28 +0800 Subject: [PATCH 05/36] luci-app-openclash: Update translate (#3807) * luci-app-openclash: Update translate * luci-app-openclash: Update translate * Update openclash.zh-cn.po --- .../model/cbi/openclash/servers-config.lua | 8 +++---- .../po/zh-cn/openclash.zh-cn.po | 23 ++++++++++++++++++- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/luci-app-openclash/luasrc/model/cbi/openclash/servers-config.lua b/luci-app-openclash/luasrc/model/cbi/openclash/servers-config.lua index 62145aad45..1b88b24078 100644 --- a/luci-app-openclash/luasrc/model/cbi/openclash/servers-config.lua +++ b/luci-app-openclash/luasrc/model/cbi/openclash/servers-config.lua @@ -167,7 +167,7 @@ o:depends("type", "hysteria2") o.rmempty = true o.default = "0" -o = s:option(Value, "ports", translate("Port Hopping")) +o = s:option(Value, "ports", translate("Port Range")) o.datatype = "portrange" o.rmempty = true o.default = "20000-40000" @@ -305,13 +305,13 @@ for _, v in ipairs(hysteria2_protocols) do o:value(v) end o.rmempty = true o:depends({type = "hysteria2", flag_transport = true}) -o = s:option(Value, "hysteria_up", translate("up")) +o = s:option(Value, "hysteria_up", translate("Uplink Capacity(Default:Mbps)")) o.rmempty = false o.description = translate("Required") o:depends("type", "hysteria") o:depends("type", "hysteria2") -o = s:option(Value, "hysteria_down", translate("down")) +o = s:option(Value, "hysteria_down", translate("Downlink Capacity(Default:Mbps)")) o.rmempty = false o.description = translate("Required") o:depends("type", "hysteria") @@ -723,7 +723,7 @@ o.datatype = "uinteger" o:depends({type = "hysteria", flag_quicparam = true}) -- [[ hop_interval ]]-- -o = s:option(Value, "hop_interval", translate("Hop Interval")) +o = s:option(Value, "hop_interval", translate("Hop Interval (Unit:second)")) o.rmempty = true o.default = "10" o:depends({type = "hysteria", flag_transport = true, flag_port_hopping = true}) 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 9d0f7a6848..148a25e5ab 100644 --- a/luci-app-openclash/po/zh-cn/openclash.zh-cn.po +++ b/luci-app-openclash/po/zh-cn/openclash.zh-cn.po @@ -726,7 +726,7 @@ msgstr "协议" msgid "Protocol param(optional)" msgstr "传输协议参数(可选)" -msgid "Obfs" +msgid "obfs" msgstr "混淆插件" msgid "Obfs param(optional)" @@ -768,6 +768,27 @@ msgstr "服务器节点配置" msgid "Enable Port Hopping" msgstr "启用端口跃迁" +msgid "Port Range" +msgstr "端口范围值" + +msgid "Uplink Capacity(Default:Mbps)" +msgstr "上行链路容量(默认:Mbps)" + +msgid "Downlink Capacity(Default:Mbps)" +msgstr "下行链路容量(默认:Mbps)" + +msgid "Hop Interval (Unit:second)" +msgstr "跳跃间隔(单位:秒)" + +msgid "Obfs" +msgstr "混淆插件" + +msgid "Obfs param (optional)" +msgstr "混淆参数(可选)" + +msgid "obfs-password" +msgstr "混淆密码" + msgid "Enable Transport Protocol Settings" msgstr "启用传输协议设置" From fb323351107d52cbccadc0d61e1caa7bc3a7b865 Mon Sep 17 00:00:00 2001 From: vernesong <42875168+vernesong@users.noreply.github.com> Date: Mon, 18 Mar 2024 22:25:22 +0800 Subject: [PATCH 06/36] 0.46.004 --- luci-app-openclash/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/luci-app-openclash/Makefile b/luci-app-openclash/Makefile index f8333d64b5..f2c7d8aaf5 100644 --- a/luci-app-openclash/Makefile +++ b/luci-app-openclash/Makefile @@ -1,7 +1,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-openclash -PKG_VERSION:=0.46.003 +PKG_VERSION:=0.46.004 PKG_RELEASE:=beta PKG_MAINTAINER:=vernesong From 7c0009cda53991922c320e6a3d170b606ff64719 Mon Sep 17 00:00:00 2001 From: vernesong <42875168+vernesong@users.noreply.github.com> Date: Tue, 19 Mar 2024 18:16:47 +0800 Subject: [PATCH 07/36] fix typo --- luci-app-openclash/root/usr/share/openclash/yml_proxys_get.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/luci-app-openclash/root/usr/share/openclash/yml_proxys_get.sh b/luci-app-openclash/root/usr/share/openclash/yml_proxys_get.sh index 74feb279c8..9bb3ec7fa2 100644 --- a/luci-app-openclash/root/usr/share/openclash/yml_proxys_get.sh +++ b/luci-app-openclash/root/usr/share/openclash/yml_proxys_get.sh @@ -1036,6 +1036,7 @@ do system(hysteria_protocol) end }.join + end; if '$server_type' == 'hysteria2' then #hysteria2 @@ -1046,6 +1047,7 @@ do system(hysteria2_protocol) end }.join + end; if '$server_type' == 'hysteria' or '$server_type' == 'hysteria2' then #hysteria hysteria2 From 6cd46b2e75f0c8863a251080b7192958c9334f5e Mon Sep 17 00:00:00 2001 From: vernesong <42875168+vernesong@users.noreply.github.com> Date: Tue, 19 Mar 2024 19:23:51 +0800 Subject: [PATCH 08/36] 0.46.005 --- luci-app-openclash/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/luci-app-openclash/Makefile b/luci-app-openclash/Makefile index f2c7d8aaf5..0178e02b8e 100644 --- a/luci-app-openclash/Makefile +++ b/luci-app-openclash/Makefile @@ -1,7 +1,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-openclash -PKG_VERSION:=0.46.004 +PKG_VERSION:=0.46.005 PKG_RELEASE:=beta PKG_MAINTAINER:=vernesong From 7b70f7985242bafac11be7394c91c48028f9ccb2 Mon Sep 17 00:00:00 2001 From: vernesong <42875168+vernesong@users.noreply.github.com> Date: Fri, 22 Mar 2024 10:11:48 +0800 Subject: [PATCH 09/36] fix #3816 --- luci-app-openclash/root/etc/init.d/openclash | 1 + luci-app-openclash/root/usr/share/openclash/openclash.sh | 1 + 2 files changed, 2 insertions(+) diff --git a/luci-app-openclash/root/etc/init.d/openclash b/luci-app-openclash/root/etc/init.d/openclash index b54031ed1f..7a9210df71 100644 --- a/luci-app-openclash/root/etc/init.d/openclash +++ b/luci-app-openclash/root/etc/init.d/openclash @@ -744,6 +744,7 @@ config_test() { if [ -f "$CLASH" ]; then LOG_OUT "Test The Config File First..." + chmod o+w "$CONFIG_FILE" 2>/dev/null test_info=$(nohup $CLASH -t -d $CLASH_CONFIG -f "$CONFIG_FILE") local IFS=$'\n' for i in $test_info; do diff --git a/luci-app-openclash/root/usr/share/openclash/openclash.sh b/luci-app-openclash/root/usr/share/openclash/openclash.sh index 7cb2f8ce8d..153469ddda 100644 --- a/luci-app-openclash/root/usr/share/openclash/openclash.sh +++ b/luci-app-openclash/root/usr/share/openclash/openclash.sh @@ -50,6 +50,7 @@ config_test() { if [ -f "$CLASH" ]; then LOG_OUT "Config File Download Successful, Test If There is Any Errors..." + chmod o+w "$CFG_FILE" 2>/dev/null test_info=$(nohup $CLASH -t -d $CLASH_CONFIG -f "$CFG_FILE") local IFS=$'\n' for i in $test_info; do From c23f1391c05a669f23eef12ab3db53d1e9567730 Mon Sep 17 00:00:00 2001 From: vernesong <42875168+vernesong@users.noreply.github.com> Date: Fri, 22 Mar 2024 10:25:10 +0800 Subject: [PATCH 10/36] chore: refine --- .../root/usr/share/openclash/yml_groups_set.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/luci-app-openclash/root/usr/share/openclash/yml_groups_set.sh b/luci-app-openclash/root/usr/share/openclash/yml_groups_set.sh index a4e8e13ea1..701a206793 100644 --- a/luci-app-openclash/root/usr/share/openclash/yml_groups_set.sh +++ b/luci-app-openclash/root/usr/share/openclash/yml_groups_set.sh @@ -312,8 +312,13 @@ yml_groups_set() sed -i "/use: ${name}/d" $GROUP_FILE 2>/dev/null fi + if [ "$set_group" -eq 0 ] && [ "$set_proxy_provider" -eq 0 ]; then + echo " proxies:" >>$GROUP_FILE + echo " - DIRECT" >>$GROUP_FILE + fi + [ -n "$test_url" ] && { - echo " url: $test_url" >>$GROUP_FILE + echo " url: $test_url" >>$GROUP_FILE } [ -n "$test_interval" ] && { echo " interval: \"$test_interval\"" >>$GROUP_FILE From 266be0a0f955c13d37a547a6aba680b33ff5955c Mon Sep 17 00:00:00 2001 From: vernesong <42875168+vernesong@users.noreply.github.com> Date: Fri, 22 Mar 2024 10:37:57 +0800 Subject: [PATCH 11/36] chore: refine --- .../luasrc/model/cbi/openclash/settings.lua | 2 +- luci-app-openclash/po/zh-cn/openclash.zh-cn.po | 8 ++++---- .../root/usr/share/openclash/openclash_core.sh | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/luci-app-openclash/luasrc/model/cbi/openclash/settings.lua b/luci-app-openclash/luasrc/model/cbi/openclash/settings.lua index 659d57be04..0e5c323dab 100644 --- a/luci-app-openclash/luasrc/model/cbi/openclash/settings.lua +++ b/luci-app-openclash/luasrc/model/cbi/openclash/settings.lua @@ -256,7 +256,7 @@ if op_mode == "redir-host" then o.default = 0 else o = s:taboption("traffic_control", Flag, "china_ip_route", translate("China IP Route")) - o.description = translate("Bypass The China Network Flows, Improve Performance, Depend on Dnsmasq") + o.description = translate("Bypass The China Network Flows, Improve Performance, If Inaccessibility on Bypass Gateway, Try to Enable Bypass Gateway Compatible Option, Depend on Dnsmasq") o.default = 0 o:depends("enable_redirect_dns", "1") o:depends("enable_redirect_dns", "0") 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 148a25e5ab..75b53ea6f4 100644 --- a/luci-app-openclash/po/zh-cn/openclash.zh-cn.po +++ b/luci-app-openclash/po/zh-cn/openclash.zh-cn.po @@ -173,8 +173,8 @@ msgstr "实验性:绕过中国大陆 IPv6" msgid "Bypass The China Network Flows, Improve Performance" msgstr "启用后中国大陆流量将不再经过内核,提升系统性能" -msgid "Bypass The China Network Flows, Improve Performance, Depend on Dnsmasq" -msgstr "启用后中国大陆流量将不再经过内核,提升系统性能,此功能依赖于 Dnsmasq" +msgid "Bypass The China Network Flows, Improve Performance, If Inaccessibility on Bypass Gateway, Try to Enable Bypass Gateway Compatible Option, Depend on Dnsmasq" +msgstr "启用后中国大陆流量将不再经过内核,提升系统性能,如旁路由遇到无法访问,请尝试启用旁路由兼容模式,此功能依赖于 Dnsmasq" msgid "Log Level" msgstr "日志等级" @@ -1674,8 +1674,8 @@ msgstr "版本内核更新成功!" msgid "Core Update Failed. Please Make Sure Enough Flash Memory Space And Try Again!" msgstr "版本内核更新失败,请确认设备闪存空间足够后再试!" -msgid "No Compiled Version Selected, Please Select In Global Settings And Try Again!" -msgstr "未选择编译版本,请到全局设置中选择后再试!" +msgid "No Compiled Version Selected, Please Select In Update Page And Try Again!" +msgstr "未选择编译版本,请到升级页面选择后再试!" msgid "Core Has Not Been Updated, Stop Continuing Operation!" msgstr "版本内核没有更新,停止继续操作!" diff --git a/luci-app-openclash/root/usr/share/openclash/openclash_core.sh b/luci-app-openclash/root/usr/share/openclash/openclash_core.sh index 5f989a63dd..28788934cf 100644 --- a/luci-app-openclash/root/usr/share/openclash/openclash_core.sh +++ b/luci-app-openclash/root/usr/share/openclash/openclash_core.sh @@ -188,7 +188,7 @@ if [ "$CORE_CV" != "$CORE_LV" ] || [ -z "$CORE_CV" ]; then SLOG_CLEAN fi else - LOG_OUT "No Compiled Version Selected, Please Select In Global Settings And Try Again!" + LOG_OUT "No Compiled Version Selected, Please Select In Update Page And Try Again!" SLOG_CLEAN fi else From e95e72c665ee9862a87f1b46554a82a7c11867f0 Mon Sep 17 00:00:00 2001 From: vernesong <42875168+vernesong@users.noreply.github.com> Date: Tue, 9 Apr 2024 05:50:42 +0800 Subject: [PATCH 12/36] chore: #3834 --- luci-app-openclash/luasrc/view/openclash/update.htm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/luci-app-openclash/luasrc/view/openclash/update.htm b/luci-app-openclash/luasrc/view/openclash/update.htm index d532a126fc..b5723613b0 100644 --- a/luci-app-openclash/luasrc/view/openclash/update.htm +++ b/luci-app-openclash/luasrc/view/openclash/update.htm @@ -15,6 +15,10 @@ + + + + From 1d2016ffafe3a8863c115019833a9392c96651ed Mon Sep 17 00:00:00 2001 From: vernesong <42875168+vernesong@users.noreply.github.com> Date: Tue, 9 Apr 2024 06:26:28 +0800 Subject: [PATCH 13/36] workflow: meta --- .github/workflows/compile_meta_core.yml | 48 ++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/.github/workflows/compile_meta_core.yml b/.github/workflows/compile_meta_core.yml index 580fcbd02f..d6b632cbf4 100644 --- a/.github/workflows/compile_meta_core.yml +++ b/.github/workflows/compile_meta_core.yml @@ -74,8 +74,20 @@ jobs: mkdir tmp/bin cp ./OpenClash/.github/makefile/meta ./tmp/Makefile + - name: Copy loongarch abi1 Makefile + run: | + cd .. + mkdir tmp/loong64_abi1/bin + cp ./OpenClash/.github/makefile/meta_loongarch_abi1 ./tmp/loong64_abi1/Makefile + + - name: Copy loongarch abi2 Makefile + run: | + cd .. + mkdir tmp/loong64_abi2/bin + cp ./OpenClash/.github/makefile/meta_loongarch_abi2 ./tmp/loong64_abi2/Makefile + - name: Setup Go - uses: actions/setup-go@v3 + uses: actions/setup-go@v5 with: go-version: "1.22" check-latest: true @@ -94,6 +106,38 @@ jobs: - name: Copy Clash Bin run: | cp -rf "./bin/." "../tmp/bin/" + rm -rf ./bin/* + + - name: Setup loongarch abi1 Go + run: | + wget -q https://github.com/xishang0128/loongarch64-golang/releases/download/1.21.5/go1.21.5.linux-amd64-abi1.tar.gz + sudo tar zxf go1.21.5.linux-amd64-abi1.tar.gz -C /usr/local + echo "/usr/local/go/bin" >> $GITHUB_PATH + + - name: Compile Meta loongarch abi1 Clash + run: | + cp ../tmp/loong64_abi1/Makefile ./Makefile + make releases + + - name: Copy loongarch abi1 Clash Bin + run: | + cp -rf "./bin/." "../tmp/loong64_abi1/bin/" + rm -rf ./bin/* + + - name: Setup loongarch abi2 Go + run: | + wget -q https://github.com/xishang0128/loongarch64-golang/releases/download/1.21.5/go1.21.5.linux-amd64-abi2.tar.gz + sudo tar zxf go1.21.5.linux-amd64-abi2.tar.gz -C /usr/local + echo "/usr/local/go/bin" >> $GITHUB_PATH + + - name: Compile Meta loongarch abi2 Clash + run: | + cp ../tmp/loong64_abi2/Makefile ./Makefile + make releases + + - name: Copy loongarch abi2 Clash Bin + run: | + cp -rf "./bin/." "../tmp/loong64_abi2/bin/" - name: Clone OpenClash Repository uses: actions/checkout@v4 @@ -109,6 +153,8 @@ jobs: run: | rm -rf ./dev/meta/* cp -rf "../tmp/bin/." "./dev/meta/" + cp -rf "../tmp/loong64_abi1/bin/." "./dev/meta/" + cp -rf "../tmp/loong64_abi2/bin/." "./dev/meta/" git config user.name 'github-actions[bot]' git config user.email 'github-actions[bot]@users.noreply.github.com' git add . From ceb0b86323381ca71f4cb0508c9ded6536d67629 Mon Sep 17 00:00:00 2001 From: vernesong <42875168+vernesong@users.noreply.github.com> Date: Tue, 9 Apr 2024 06:36:28 +0800 Subject: [PATCH 14/36] workflow: refine --- .github/workflows/compile_meta_core.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/compile_meta_core.yml b/.github/workflows/compile_meta_core.yml index d6b632cbf4..336bf602f5 100644 --- a/.github/workflows/compile_meta_core.yml +++ b/.github/workflows/compile_meta_core.yml @@ -110,12 +110,14 @@ jobs: - name: Setup loongarch abi1 Go run: | + cd .. wget -q https://github.com/xishang0128/loongarch64-golang/releases/download/1.21.5/go1.21.5.linux-amd64-abi1.tar.gz sudo tar zxf go1.21.5.linux-amd64-abi1.tar.gz -C /usr/local echo "/usr/local/go/bin" >> $GITHUB_PATH - name: Compile Meta loongarch abi1 Clash run: | + cd mihomo cp ../tmp/loong64_abi1/Makefile ./Makefile make releases @@ -126,12 +128,13 @@ jobs: - name: Setup loongarch abi2 Go run: | + cd .. wget -q https://github.com/xishang0128/loongarch64-golang/releases/download/1.21.5/go1.21.5.linux-amd64-abi2.tar.gz sudo tar zxf go1.21.5.linux-amd64-abi2.tar.gz -C /usr/local - echo "/usr/local/go/bin" >> $GITHUB_PATH - name: Compile Meta loongarch abi2 Clash run: | + cd mihomo cp ../tmp/loong64_abi2/Makefile ./Makefile make releases From 19fe6f62ba619a4b60ea77b59b950d99ea921ba9 Mon Sep 17 00:00:00 2001 From: vernesong <42875168+vernesong@users.noreply.github.com> Date: Tue, 9 Apr 2024 14:35:38 +0800 Subject: [PATCH 15/36] workflow: fix typo --- .github/workflows/compile_meta_core.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/compile_meta_core.yml b/.github/workflows/compile_meta_core.yml index 336bf602f5..8fb2785f9d 100644 --- a/.github/workflows/compile_meta_core.yml +++ b/.github/workflows/compile_meta_core.yml @@ -77,13 +77,13 @@ jobs: - name: Copy loongarch abi1 Makefile run: | cd .. - mkdir tmp/loong64_abi1/bin + mkdir -p tmp/loong64_abi1/bin cp ./OpenClash/.github/makefile/meta_loongarch_abi1 ./tmp/loong64_abi1/Makefile - name: Copy loongarch abi2 Makefile run: | cd .. - mkdir tmp/loong64_abi2/bin + mkdir -p tmp/loong64_abi2/bin cp ./OpenClash/.github/makefile/meta_loongarch_abi2 ./tmp/loong64_abi2/Makefile - name: Setup Go From 3c4a0f7020a232ba9d9886566cef931778ed92d6 Mon Sep 17 00:00:00 2001 From: vernesong <42875168+vernesong@users.noreply.github.com> Date: Tue, 9 Apr 2024 15:27:32 +0800 Subject: [PATCH 16/36] workflow: test --- .github/workflows/compile_meta_core.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/compile_meta_core.yml b/.github/workflows/compile_meta_core.yml index 8fb2785f9d..859d345bda 100644 --- a/.github/workflows/compile_meta_core.yml +++ b/.github/workflows/compile_meta_core.yml @@ -100,6 +100,7 @@ jobs: - name: Compile Meta Clash run: | + pwd cp ../tmp/Makefile ./Makefile make releases From 978596691ba8824c74e112827151e33b94fdba02 Mon Sep 17 00:00:00 2001 From: vernesong <42875168+vernesong@users.noreply.github.com> Date: Tue, 9 Apr 2024 15:31:19 +0800 Subject: [PATCH 17/36] workflow: fix error --- .github/workflows/compile_meta_core.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/compile_meta_core.yml b/.github/workflows/compile_meta_core.yml index 859d345bda..509dd99f4b 100644 --- a/.github/workflows/compile_meta_core.yml +++ b/.github/workflows/compile_meta_core.yml @@ -100,7 +100,6 @@ jobs: - name: Compile Meta Clash run: | - pwd cp ../tmp/Makefile ./Makefile make releases @@ -118,7 +117,7 @@ jobs: - name: Compile Meta loongarch abi1 Clash run: | - cd mihomo + cd OpenClash cp ../tmp/loong64_abi1/Makefile ./Makefile make releases @@ -135,7 +134,7 @@ jobs: - name: Compile Meta loongarch abi2 Clash run: | - cd mihomo + cd OpenClash cp ../tmp/loong64_abi2/Makefile ./Makefile make releases From 316e979cbbf82334da8da004d7f8ef8d8cd7e6c9 Mon Sep 17 00:00:00 2001 From: vernesong <42875168+vernesong@users.noreply.github.com> Date: Tue, 9 Apr 2024 22:32:39 +0800 Subject: [PATCH 18/36] workflow: refine --- .github/workflows/compile_meta_core.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/compile_meta_core.yml b/.github/workflows/compile_meta_core.yml index 509dd99f4b..96814cb643 100644 --- a/.github/workflows/compile_meta_core.yml +++ b/.github/workflows/compile_meta_core.yml @@ -110,14 +110,12 @@ jobs: - name: Setup loongarch abi1 Go run: | - cd .. wget -q https://github.com/xishang0128/loongarch64-golang/releases/download/1.21.5/go1.21.5.linux-amd64-abi1.tar.gz sudo tar zxf go1.21.5.linux-amd64-abi1.tar.gz -C /usr/local echo "/usr/local/go/bin" >> $GITHUB_PATH - name: Compile Meta loongarch abi1 Clash run: | - cd OpenClash cp ../tmp/loong64_abi1/Makefile ./Makefile make releases @@ -128,13 +126,11 @@ jobs: - name: Setup loongarch abi2 Go run: | - cd .. wget -q https://github.com/xishang0128/loongarch64-golang/releases/download/1.21.5/go1.21.5.linux-amd64-abi2.tar.gz sudo tar zxf go1.21.5.linux-amd64-abi2.tar.gz -C /usr/local - name: Compile Meta loongarch abi2 Clash run: | - cd OpenClash cp ../tmp/loong64_abi2/Makefile ./Makefile make releases From 3d554272fbf5977078729c87ed8266e62b3f5be2 Mon Sep 17 00:00:00 2001 From: vernesong <42875168+vernesong@users.noreply.github.com> Date: Tue, 9 Apr 2024 23:24:37 +0800 Subject: [PATCH 19/36] 0.46.006 --- luci-app-openclash/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/luci-app-openclash/Makefile b/luci-app-openclash/Makefile index 0178e02b8e..f1a0ac526b 100644 --- a/luci-app-openclash/Makefile +++ b/luci-app-openclash/Makefile @@ -1,7 +1,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-openclash -PKG_VERSION:=0.46.005 +PKG_VERSION:=0.46.006 PKG_RELEASE:=beta PKG_MAINTAINER:=vernesong From e110c06922b6b883de5de7c187afb19f57fb7796 Mon Sep 17 00:00:00 2001 From: vernesong <42875168+vernesong@users.noreply.github.com> Date: Wed, 10 Apr 2024 10:40:37 +0800 Subject: [PATCH 20/36] fix typo --- luci-app-openclash/luasrc/view/openclash/update.htm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/luci-app-openclash/luasrc/view/openclash/update.htm b/luci-app-openclash/luasrc/view/openclash/update.htm index b5723613b0..803356389f 100644 --- a/luci-app-openclash/luasrc/view/openclash/update.htm +++ b/luci-app-openclash/luasrc/view/openclash/update.htm @@ -16,7 +16,7 @@ - + From f8ddf1ec1930d11faa655c6ab882e1513a3b6f64 Mon Sep 17 00:00:00 2001 From: vernesong <42875168+vernesong@users.noreply.github.com> Date: Sat, 13 Apr 2024 18:35:15 +0800 Subject: [PATCH 21/36] chore: refine ip result --- .../luasrc/view/openclash/myip.htm | 79 ++++++++----------- .../po/zh-cn/openclash.zh-cn.po | 6 -- 2 files changed, 35 insertions(+), 50 deletions(-) diff --git a/luci-app-openclash/luasrc/view/openclash/myip.htm b/luci-app-openclash/luasrc/view/openclash/myip.htm index 7a4ebb1193..643b795c34 100644 --- a/luci-app-openclash/luasrc/view/openclash/myip.htm +++ b/luci-app-openclash/luasrc/view/openclash/myip.htm @@ -6,15 +6,15 @@ - - + + - - + + @@ -63,22 +63,22 @@ .ip-result { font-size:15px; margin:0px 0px 0px 5%; - white-space: nowrap; /*强制span不换行*/ - display: inline-block; /*将span当做块级元素对待*/ - width: 32%; /*限制宽度*/ - overflow: hidden; /*超出宽度部分隐藏*/ - text-overflow: ellipsis; /*超出部分以点号代替*/ + white-space: nowrap; + display: inline-block; + width: 32%; + overflow: hidden; + text-overflow: ellipsis; vertical-align:bottom; } .ip-geo { font-size:15px; line-height:20px; - white-space: nowrap; /*强制span不换行*/ - display: inline-block; /*将span当做块级元素对待*/ - width: 35%; /*限制宽度*/ - overflow: hidden; /*超出宽度部分隐藏*/ - text-overflow: ellipsis; /*超出部分以点号代替*/ + white-space: nowrap; + display: inline-block; + width: 35%; + overflow: hidden; + text-overflow: ellipsis; text-align: right; vertical-align:bottom; } @@ -142,18 +142,17 @@

<%:IP Address%> <%:Hide IP%>

-

- IP.TB    <%:Mainland%>: + SpeedTest:

- IP.PC    <%:Mainland%>: + PConline:

- IP.SB    <%:Abroad%>: + IP.SB:

- IPIFY    <%:Abroad%>: + IPIFY:

@@ -190,13 +189,13 @@ const $$ = document; var ip_pcol_ip; var ip_ipsb_ip; - var ip_taobao_ip; + var ip_speedtest_ip; var ip_ipify_ip; var refresh_http; var refresh_ip; $$.getElementById('ip-pcol').innerHTML = '<%:Querying...%>'; $$.getElementById('ip-ipify').innerHTML = '<%:Querying...%>'; - $$.getElementById('ip-taobao').innerHTML = '<%:Querying...%>'; + $$.getElementById('ip-speedtest').innerHTML = '<%:Querying...%>'; $$.getElementById('ip-ipsb').innerHTML = '<%:Querying...%>'; let random = parseInt(Math.random() * 100000000); let IP = { @@ -266,7 +265,7 @@ if (localStorage.getItem('privacy_my_ip') != 'true') { $$.getElementById('ip-speedtest').innerHTML = resp.data.ip; }; - $$.getElementById('ip-speedtest-geo').innerHTML = resp.data.country + resp.data.province + resp.data.city + (resp.data.distinct == "null" ? resp.data.distinct : '') + ' ' + (resp.data.isp == "null" ? resp.data.isp : ''); + $$.getElementById('ip-speedtest-geo').innerHTML = resp.data.country + resp.data.province + resp.data.city + (resp.data.distinct == "null" ? '' : resp.data.distinct) + ' ' + (resp.data.isp == "null" ? '' : resp.data.isp); //IP.parseIPIpip(resp.data.ip, 'ip-speedtest-geo'); }) }, @@ -350,20 +349,19 @@ IP.parseIPIpip(data.ip, 'ip-ipsb-geo'); }; - function ipCallback(data){ - if (localStorage.getItem('privacy_my_ip') != 'true') { - $$.getElementById('ip-taobao').innerHTML = data.ip; - }; - IP.parseIPIpip(data.ip, 'ip-taobao-geo'); - }; + //function ipCallback(data){ + // if (localStorage.getItem('privacy_my_ip') != 'true') { + // $$.getElementById('ip-taobao').innerHTML = data.ip; + // }; + // IP.parseIPIpip(data.ip, 'ip-taobao-geo'); + //}; function delete_ip_script() { var scripts = document.getElementsByTagName('script'); for (var i = scripts.length; i--; ) { if (document.getElementsByTagName("script")[i]['src'].indexOf('whois.pconline.com.cn') > -1 - || document.getElementsByTagName("script")[i]['src'].indexOf('api-ipv4.ip.sb') > -1 - || document.getElementsByTagName("script")[i]['src'].indexOf('www.taobao.com') > -1) { + || document.getElementsByTagName("script")[i]['src'].indexOf('api-ipv4.ip.sb') > -1) { scripts[i].parentNode.removeChild(scripts[i]); }; }; @@ -384,14 +382,9 @@ sbipScript.src='https://api-ipv4.ip.sb/jsonip?callback=getIpsbIP'; mypage.appendChild(sbipScript); - var tbipScript= document.createElement("script"); - tbipScript.defer = "defer"; - tbipScript.src='https://www.taobao.com/help/getip.php?callback=ipCallback'; - mypage.appendChild(tbipScript); - //HTTP.runcheck(); + IP.getSpeedIP(); IP.getIpifyIP(); - //IP.getSpeedIP(); }; function show_my_ip() @@ -402,11 +395,11 @@ $$.getElementById('eye-icon').alt='<%:Show IP%>'; ip_pcol_ip = $$.getElementById('ip-pcol').innerHTML; ip_ipsb_ip = $$.getElementById('ip-ipsb').innerHTML; - ip_taobao_ip = $$.getElementById('ip-taobao').innerHTML; + ip_speedtest_ip = $$.getElementById('ip-speedtest').innerHTML; ip_ipify_ip = $$.getElementById('ip-ipify').innerHTML; $$.getElementById('ip-pcol').innerHTML = '***.***.***.***'; $$.getElementById('ip-ipsb').innerHTML = '***.***.***.***'; - $$.getElementById('ip-taobao').innerHTML = '***.***.***.***'; + $$.getElementById('ip-speedtest').innerHTML = '***.***.***.***'; $$.getElementById('ip-ipify').innerHTML = '***.***.***.***'; } else { @@ -426,13 +419,12 @@ imgobj.alt='<%:Show IP%>'; ip_pcol_ip = $$.getElementById('ip-pcol').innerHTML; ip_ipsb_ip = $$.getElementById('ip-ipsb').innerHTML; - ip_taobao_ip = $$.getElementById('ip-taobao').innerHTML; + ip_speedtest_ip = $$.getElementById('ip-speedtest').innerHTML; ip_ipify_ip = $$.getElementById('ip-ipify').innerHTML; $$.getElementById('ip-pcol').innerHTML = '***.***.***.***'; $$.getElementById('ip-ipsb').innerHTML = '***.***.***.***'; - $$.getElementById('ip-taobao').innerHTML = '***.***.***.***'; + $$.getElementById('ip-speedtest').innerHTML = '***.***.***.***'; $$.getElementById('ip-ipify').innerHTML = '***.***.***.***'; - } else { imgobj.src='/luci-static/resources/openclash/img/eye-light.svg'; @@ -440,7 +432,7 @@ imgobj.alt='<%:Hide IP%>'; $$.getElementById('ip-pcol').innerHTML = ip_pcol_ip; $$.getElementById('ip-ipsb').innerHTML = ip_ipsb_ip; - $$.getElementById('ip-taobao').innerHTML = ip_taobao_ip; + $$.getElementById('ip-speedtest').innerHTML = ip_speedtest_ip; $$.getElementById('ip-ipify').innerHTML = ip_ipify_ip; localStorage.removeItem('privacy_my_ip'); myip_Load(); @@ -460,12 +452,11 @@ HTTP.runcheck(); IP.getIpifyIP(); - //IP.getSpeedIP(); + IP.getSpeedIP(); show_my_ip(); - 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 75b53ea6f4..78eae34413 100644 --- a/luci-app-openclash/po/zh-cn/openclash.zh-cn.po +++ b/luci-app-openclash/po/zh-cn/openclash.zh-cn.po @@ -1455,12 +1455,6 @@ msgstr "页面已切换为 Redir-Host 模式!" msgid "IP Address" msgstr "IP 地址" -msgid "Mainland" -msgstr "国内" - -msgid "Abroad" -msgstr "国外" - msgid "Website Access Check" msgstr "网站访问检查" From a7281cb235a7f53ff489fc9f2a2c5b53a81f82c2 Mon Sep 17 00:00:00 2001 From: vernesong <42875168+vernesong@users.noreply.github.com> Date: Mon, 15 Apr 2024 07:56:46 +0800 Subject: [PATCH 22/36] chore: refine --- luci-app-openclash/luasrc/view/openclash/myip.htm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/luci-app-openclash/luasrc/view/openclash/myip.htm b/luci-app-openclash/luasrc/view/openclash/myip.htm index 643b795c34..ac044e5c39 100644 --- a/luci-app-openclash/luasrc/view/openclash/myip.htm +++ b/luci-app-openclash/luasrc/view/openclash/myip.htm @@ -265,8 +265,8 @@ if (localStorage.getItem('privacy_my_ip') != 'true') { $$.getElementById('ip-speedtest').innerHTML = resp.data.ip; }; - $$.getElementById('ip-speedtest-geo').innerHTML = resp.data.country + resp.data.province + resp.data.city + (resp.data.distinct == "null" ? '' : resp.data.distinct) + ' ' + (resp.data.isp == "null" ? '' : resp.data.isp); - //IP.parseIPIpip(resp.data.ip, 'ip-speedtest-geo'); + //$$.getElementById('ip-speedtest-geo').innerHTML = resp.data.country + resp.data.province + resp.data.city + (resp.data.distinct == "null" ? '' : resp.data.distinct) + ' ' + (resp.data.isp == "null" ? '' : resp.data.isp); + IP.parseIPIpip(resp.data.ip, 'ip-speedtest-geo'); }) }, getIpifyIP: () => { From 5f0a7c0335b86a2d7e8ae350117c3220654c4cad Mon Sep 17 00:00:00 2001 From: vernesong <42875168+vernesong@users.noreply.github.com> Date: Mon, 15 Apr 2024 07:57:01 +0800 Subject: [PATCH 23/36] 0.46.007 --- luci-app-openclash/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/luci-app-openclash/Makefile b/luci-app-openclash/Makefile index f1a0ac526b..aba2134df1 100644 --- a/luci-app-openclash/Makefile +++ b/luci-app-openclash/Makefile @@ -1,7 +1,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-openclash -PKG_VERSION:=0.46.006 +PKG_VERSION:=0.46.007 PKG_RELEASE:=beta PKG_MAINTAINER:=vernesong From c0cd0f19901d418c18261a8a2efbbcb25e57a68c Mon Sep 17 00:00:00 2001 From: zxlhhyccc <45259624+zxlhhyccc@users.noreply.github.com> Date: Sat, 20 Apr 2024 07:04:51 +0800 Subject: [PATCH 24/36] Fixed an issue with the official latest master branch not working. (#3853) * Fixed an issue with the official latest master branch not working. *** compatible lede *** luci-base: conversion of ucitrack handling from uci to json. See the official commit for details: https://github.com/openwrt/luci/commit/d5c413d2853fde0d5cec98641606a0a30f93281c * Fixed an issue with the official latest master branch not working. *** compatible lede *** luci-base: conversion of ucitrack handling from uci to json. See the official commit for details: https://github.com/openwrt/luci/commit/d5c413d2853fde0d5cec98641606a0a30f93281c --- luci-app-openclash/root/etc/uci-defaults/luci-openclash | 2 ++ .../root/usr/share/ucitrack/luci-app-openclash.json | 4 ++++ 2 files changed, 6 insertions(+) create mode 100644 luci-app-openclash/root/usr/share/ucitrack/luci-app-openclash.json diff --git a/luci-app-openclash/root/etc/uci-defaults/luci-openclash b/luci-app-openclash/root/etc/uci-defaults/luci-openclash index a3f792fafd..b580de8fc1 100644 --- a/luci-app-openclash/root/etc/uci-defaults/luci-openclash +++ b/luci-app-openclash/root/etc/uci-defaults/luci-openclash @@ -1,10 +1,12 @@ #!/bin/bash . /lib/functions.sh +[ -e "/etc/config/ucitrack" ] && { uci -q delete ucitrack.@openclash[-1] uci -q add ucitrack openclash uci -q set ucitrack.@openclash[-1].init=openclash uci -q commit ucitrack +} uci -q delete firewall.openclash uci -q set firewall.openclash=include uci -q set firewall.openclash.type=script diff --git a/luci-app-openclash/root/usr/share/ucitrack/luci-app-openclash.json b/luci-app-openclash/root/usr/share/ucitrack/luci-app-openclash.json new file mode 100644 index 0000000000..841eddb87b --- /dev/null +++ b/luci-app-openclash/root/usr/share/ucitrack/luci-app-openclash.json @@ -0,0 +1,4 @@ +{ + "config": "openclash", + "init": "openclash" +} From e9575929f8bbec1c511dc237aefe5d5a33733e6f Mon Sep 17 00:00:00 2001 From: vernesong <42875168+vernesong@users.noreply.github.com> Date: Sun, 28 Apr 2024 16:10:53 +0800 Subject: [PATCH 25/36] chore: refine --- .../po/zh-cn/openclash.zh-cn.po | 7 +++++-- .../usr/share/openclash/openclash_core.sh | 21 +++++++++++-------- .../usr/share/openclash/openclash_watchdog.sh | 4 ++++ 3 files changed, 21 insertions(+), 11 deletions(-) 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 78eae34413..0bc3334e1e 100644 --- a/luci-app-openclash/po/zh-cn/openclash.zh-cn.po +++ b/luci-app-openclash/po/zh-cn/openclash.zh-cn.po @@ -1665,8 +1665,8 @@ msgstr "版本内核更新失败,请检查网络或稍后再试!" msgid "Core Update Successful!" msgstr "版本内核更新成功!" -msgid "Core Update Failed. Please Make Sure Enough Flash Memory Space And Try Again!" -msgstr "版本内核更新失败,请确认设备闪存空间足够后再试!" +msgid "Core Update Failed. Please Make Sure Enough Flash Memory Space or Selected Correct Core Platform And Try Again!" +msgstr "版本内核更新失败,请确认设备闪存空间足够或内核平台正确后再试!" msgid "No Compiled Version Selected, Please Select In Update Page And Try Again!" msgstr "未选择编译版本,请到升级页面选择后再试!" @@ -3521,3 +3521,6 @@ msgstr "绕过服务器地址" msgid "Bypassing Server Addresses And Preventing Duplicate Proxies" msgstr "绕过服务器地址,防止重复代理" + +msgid "Warning: Unsupported format, Proxies Address Skip Function Ignore Proxy-providers File" +msgstr "警告:不支持的格式,绕过代理服务器地址功能已忽略代理集文件" diff --git a/luci-app-openclash/root/usr/share/openclash/openclash_core.sh b/luci-app-openclash/root/usr/share/openclash/openclash_core.sh index 28788934cf..0d925f72ef 100644 --- a/luci-app-openclash/root/usr/share/openclash/openclash_core.sh +++ b/luci-app-openclash/root/usr/share/openclash/openclash_core.sh @@ -115,13 +115,14 @@ if [ "$CORE_CV" != "$CORE_LV" ] || [ -z "$CORE_CV" ]; then if [ "$?" == "0" ]; then LOG_OUT "【"$CORE_TYPE"】Core Download Successful, Start Update..." - case $CORE_TYPE in + case $CORE_TYPE in "TUN") [ -s "/tmp/clash_tun.gz" ] && { gzip -d /tmp/clash_tun.gz >/dev/null 2>&1 rm -rf /tmp/clash_tun.gz >/dev/null 2>&1 rm -rf "$tun_core_path" >/dev/null 2>&1 chmod 4755 /tmp/clash_tun >/dev/null 2>&1 + /tmp/clash_tun -v >/dev/null 2>&1 } ;; "Meta") @@ -131,6 +132,7 @@ if [ "$CORE_CV" != "$CORE_LV" ] || [ -z "$CORE_CV" ]; then mv /tmp/clash /tmp/clash_meta >/dev/null 2>&1 rm -rf /tmp/clash_meta.tar.gz >/dev/null 2>&1 chmod 4755 /tmp/clash_meta >/dev/null 2>&1 + /tmp/clash_meta -v >/dev/null 2>&1 } ;; *) @@ -139,10 +141,11 @@ if [ "$CORE_CV" != "$CORE_LV" ] || [ -z "$CORE_CV" ]; then tar zxvf /tmp/clash.tar.gz -C /tmp rm -rf /tmp/clash.tar.gz >/dev/null 2>&1 chmod 4755 /tmp/clash >/dev/null 2>&1 + /tmp/clash -v >/dev/null 2>&1 } esac if [ "$?" != "0" ]; then - LOG_OUT "【"$CORE_TYPE"】Core Update Failed. Please Make Sure Enough Flash Memory Space And Try Again!" + LOG_OUT "【"$CORE_TYPE"】Core Update Failed. Please Make Sure Enough Flash Memory Space or Selected Correct Core Platform And Try Again!" case $CORE_TYPE in "TUN") rm -rf /tmp/clash_tun >/dev/null 2>&1 @@ -157,16 +160,16 @@ if [ "$CORE_CV" != "$CORE_LV" ] || [ -z "$CORE_CV" ]; then exit 0 fi - case $CORE_TYPE in + case $CORE_TYPE in "TUN") - mv /tmp/clash_tun "$tun_core_path" >/dev/null 2>&1 - ;; + mv /tmp/clash_tun "$tun_core_path" >/dev/null 2>&1 + ;; "Meta") - mv /tmp/clash_meta "$meta_core_path" >/dev/null 2>&1 - ;; + mv /tmp/clash_meta "$meta_core_path" >/dev/null 2>&1 + ;; *) - mv /tmp/clash "$dev_core_path" >/dev/null 2>&1 - esac + mv /tmp/clash "$dev_core_path" >/dev/null 2>&1 + esac if [ "$?" == "0" ]; then LOG_OUT "【"$CORE_TYPE"】Core Update Successful!" diff --git a/luci-app-openclash/root/usr/share/openclash/openclash_watchdog.sh b/luci-app-openclash/root/usr/share/openclash/openclash_watchdog.sh index e412ecb5ad..79f1ea99f5 100644 --- a/luci-app-openclash/root/usr/share/openclash/openclash_watchdog.sh +++ b/luci-app-openclash/root/usr/share/openclash/openclash_watchdog.sh @@ -364,6 +364,10 @@ fi path = i['path'] end; if File::exist?(path) then + if YAML.load_file(path).class == String then + puts '${LOGTIME} Warning: Unsupported format, Proxies Address Skip Function Ignore Proxy-providers File【' + path + '】'; + next + end; if YAML.load_file(path).key?('proxies') and not YAML.load_file(path)['proxies'].nil? then YAML.load_file(path)['proxies'].each do |j| From dc14419562adeb70ed9b9774dfe60f6af075e0e3 Mon Sep 17 00:00:00 2001 From: vernesong <42875168+vernesong@users.noreply.github.com> Date: Tue, 30 Apr 2024 02:15:41 +0800 Subject: [PATCH 26/36] chore: #3863 --- luci-app-openclash/Makefile | 3 -- luci-app-openclash/root/etc/init.d/openclash | 36 +++++++++++++++++-- .../root/etc/uci-defaults/luci-openclash | 23 ------------ 3 files changed, 33 insertions(+), 29 deletions(-) diff --git a/luci-app-openclash/Makefile b/luci-app-openclash/Makefile index aba2134df1..77e5c9a0b7 100644 --- a/luci-app-openclash/Makefile +++ b/luci-app-openclash/Makefile @@ -145,9 +145,6 @@ define Package/$(PKG_NAME)/postrm uci -q commit firewall uci -q delete ucitrack.@openclash[-1] uci -q commit ucitrack - uci -q delete network.utun - uci -q commit network - /etc/init.d/network restart >/dev/null 2>&1 & rm -rf /tmp/luci-* exit 0 endef diff --git a/luci-app-openclash/root/etc/init.d/openclash b/luci-app-openclash/root/etc/init.d/openclash index 7a9210df71..f599a613df 100644 --- a/luci-app-openclash/root/etc/init.d/openclash +++ b/luci-app-openclash/root/etc/init.d/openclash @@ -1842,6 +1842,9 @@ if [ -n "$FW4" ]; then #TUN FORWORD nft insert rule inet fw4 forward position 0 meta l4proto {tcp,udp} oifname utun counter accept comment \"OpenClash TUN Forward\" + nft insert rule inet fw4 forward position 0 meta l4proto {tcp,udp} iifname utun counter accept comment \"OpenClash TUN Forward\" + nft insert rule inet fw4 input position 0 meta l4proto {tcp,udp} iifname utun counter accept comment \"OpenClash TUN Input\" + nft insert rule inet fw4 srcnat position 0 meta nfproto {ipv4} oifname utun counter return comment \"OpenClash TUN Postrouting\" #quic if [ "$disable_udp_quic" -eq 1 ]; then @@ -2130,9 +2133,21 @@ if [ -n "$FW4" ]; then set_tun_tap "v6" fi + #TUN FORWORD + if [ "$ipv6_mode" -eq 2 ]; then + nft insert rule inet fw4 forward position 0 meta nfproto {ipv6} oifname utun counter accept comment \"OpenClash TUN Forward\" + nft insert rule inet fw4 forward position 0 meta nfproto {ipv6} iifname utun counter accept comment \"OpenClash TUN Forward\" + nft insert rule inet fw4 input position 0 meta nfproto {ipv6} iifname utun counter accept comment \"OpenClash TUN Input\" + nft insert rule inet fw4 srcnat position 0 meta nfproto {ipv6} oifname utun counter return comment \"OpenClash TUN Postrouting\" + fi + #quic if [ "$disable_udp_quic" -eq 1 ]; then - nft insert rule inet fw4 input position 0 udp dport 443 ip6 daddr != @china_ip6_route counter reject comment \"OpenClash QUIC REJECT\" + if [ "$ipv6_mode" -eq 2 ]; then + nft insert rule inet fw4 forward position 0 udp dport 443 ip6 daddr != @china_ip6_route counter reject comment \"OpenClash QUIC REJECT\" + else + nft insert rule inet fw4 input position 0 udp dport 443 ip6 daddr != @china_ip6_route counter reject comment \"OpenClash QUIC REJECT\" + fi fi #bypass gateway compatible @@ -2618,7 +2633,10 @@ if [ -z "$FW4" ]; then fi #TUN FORWORD - iptables -I FORWARD -m comment --comment "OpenClash TUN Forward" -o utun -j ACCEPT + iptables -I FORWARD -m comment --comment "OpenClash TUN Forward" -o utun -j ACCEPT >/dev/null 2>&1 + iptables -I FORWARD -m comment --comment "OpenClash TUN Forward" -i utun -j ACCEPT >/dev/null 2>&1 + iptables -I INPUT -m comment --comment "OpenClash TUN Input" -i utun -j ACCEPT >/dev/null 2>&1 + iptables -t nat -I POSTROUTING -m comment --comment "OpenClash TUN Postrouting" -o utun -j RETURN >/dev/null 2>&1 #quic if [ "$disable_udp_quic" -eq 1 ]; then @@ -2890,9 +2908,21 @@ if [ -z "$FW4" ]; then set_tun_tap "v6" fi + #TUN FORWORD + if [ "$ipv6_mode" -eq 2 ]; then + ip6tables -I FORWARD -m comment --comment "OpenClash TUN Forward" -o utun -j ACCEPT >/dev/null 2>&1 + ip6tables -I FORWARD -m comment --comment "OpenClash TUN Forward" -i utun -j ACCEPT >/dev/null 2>&1 + ip6tables -I INPUT -m comment --comment "OpenClash TUN Input" -i utun -j ACCEPT >/dev/null 2>&1 + ip6tables -t nat -I POSTROUTING -m comment --comment "OpenClash TUN Postrouting" -o utun -j RETURN >/dev/null 2>&1 + fi + #quic if [ "$disable_udp_quic" -eq 1 ]; then - ip6tables -I INPUT -p udp --dport 443 -m comment --comment "OpenClash QUIC REJECT" -m set ! --match-set china_ip6_route dst -j REJECT >/dev/null 2>&1 + if [ "$ipv6_mode" -eq 2 ]; then + ip6tables -I FORWARD -p udp --dport 443 -o utun -m comment --comment "OpenClash QUIC REJECT" -m set ! --match-set china_ip_route dst -j REJECT >/dev/null 2>&1 + else + ip6tables -I INPUT -p udp --dport 443 -m comment --comment "OpenClash QUIC REJECT" -m set ! --match-set china_ip6_route dst -j REJECT >/dev/null 2>&1 + fi fi #bypass gateway compatible diff --git a/luci-app-openclash/root/etc/uci-defaults/luci-openclash b/luci-app-openclash/root/etc/uci-defaults/luci-openclash index b580de8fc1..57db341641 100644 --- a/luci-app-openclash/root/etc/uci-defaults/luci-openclash +++ b/luci-app-openclash/root/etc/uci-defaults/luci-openclash @@ -198,28 +198,5 @@ sed -i '/.*kB maximum content size*/c\export let HTTP_MAX_CONTENT = 1024*10240; /etc/init.d/uhttpd restart >/dev/null 2>&1 -#set tun interface firewall rule -add_utun_firewall_zone() -{ - local section="$1" - local name network - config_get "name" "$section" "name" "" - config_get "network" "$section" "network" "" - if [ "$name" = "lan" ] && [ -z "$(echo $network |grep utun)" ]; then - uci -q add_list firewall."$section".network="utun" - uci -q commit firewall - fi -} - -uci -q set network.utun=interface -uci -q set network.utun.proto=none -uci -q set network.utun.ifname=utun -uci -q set network.utun.device=utun -uci -q set network.utun.auto='0' -uci -q commit network - -config_load "firewall" -config_foreach add_utun_firewall_zone "zone" - rm -f /tmp/luci-indexcache exit 0 From 7256d89a39e9db4c971076c841347d203360878f Mon Sep 17 00:00:00 2001 From: vernesong <42875168+vernesong@users.noreply.github.com> Date: Tue, 30 Apr 2024 02:19:06 +0800 Subject: [PATCH 27/36] 0.46.008 --- luci-app-openclash/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/luci-app-openclash/Makefile b/luci-app-openclash/Makefile index 77e5c9a0b7..ce5b9cc3b4 100644 --- a/luci-app-openclash/Makefile +++ b/luci-app-openclash/Makefile @@ -1,7 +1,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-openclash -PKG_VERSION:=0.46.007 +PKG_VERSION:=0.46.008 PKG_RELEASE:=beta PKG_MAINTAINER:=vernesong From e26adde4fc4669ddb6ad168498961dc6da37570a Mon Sep 17 00:00:00 2001 From: vernesong <42875168+vernesong@users.noreply.github.com> Date: Wed, 1 May 2024 18:14:12 +0800 Subject: [PATCH 28/36] fix typo --- luci-app-openclash/root/etc/init.d/openclash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/luci-app-openclash/root/etc/init.d/openclash b/luci-app-openclash/root/etc/init.d/openclash index f599a613df..7f53fadd56 100644 --- a/luci-app-openclash/root/etc/init.d/openclash +++ b/luci-app-openclash/root/etc/init.d/openclash @@ -2919,7 +2919,7 @@ if [ -z "$FW4" ]; then #quic if [ "$disable_udp_quic" -eq 1 ]; then if [ "$ipv6_mode" -eq 2 ]; then - ip6tables -I FORWARD -p udp --dport 443 -o utun -m comment --comment "OpenClash QUIC REJECT" -m set ! --match-set china_ip_route dst -j REJECT >/dev/null 2>&1 + ip6tables -I FORWARD -p udp --dport 443 -o utun -m comment --comment "OpenClash QUIC REJECT" -m set ! --match-set china_ip6_route dst -j REJECT >/dev/null 2>&1 else ip6tables -I INPUT -p udp --dport 443 -m comment --comment "OpenClash QUIC REJECT" -m set ! --match-set china_ip6_route dst -j REJECT >/dev/null 2>&1 fi From baddc425e600287d85b1f8cb3e576c7015f89061 Mon Sep 17 00:00:00 2001 From: shendageasw Date: Sun, 5 May 2024 02:11:32 +0800 Subject: [PATCH 29/36] config: readjust the fallback group (#3872) Here are the changes: remove option port They all use standard ports, so reassigning ports is not necessary add quad9-DNS to the fallback group add google DoH to the fallback group rearrange the order by option type change to udp type google dns of tls type already exists reorder option to the fallback group Co-authored-by: example --- luci-app-openclash/root/etc/config/openclash | 108 +++++++++++++------ 1 file changed, 75 insertions(+), 33 deletions(-) diff --git a/luci-app-openclash/root/etc/config/openclash b/luci-app-openclash/root/etc/config/openclash index 1dd0fd7f64..96527417b7 100644 --- a/luci-app-openclash/root/etc/config/openclash +++ b/luci-app-openclash/root/etc/config/openclash @@ -123,88 +123,130 @@ config dns_servers option enabled '1' config dns_servers - option type 'https' - option group 'fallback' - option ip 'dns.cloudflare.com/dns-query' option enabled '0' + option group 'fallback' + option ip '9.9.9.9' + option type 'udp' config dns_servers - option group 'fallback' - option ip 'dns.google' - option port '853' - option type 'tls' option enabled '0' + option group 'fallback' + option ip '149.112.112.112' + option type 'udp' config dns_servers - option group 'fallback' - option type 'https' - option ip '1.1.1.1/dns-query' option enabled '0' + option group 'fallback' + option ip '2620:fe::fe' + option type 'udp' config dns_servers - option group 'fallback' - option ip '1.1.1.1' - option port '853' - option type 'tls' option enabled '0' + option group 'fallback' + option ip '2620:fe::9' + option type 'udp' config dns_servers option enabled '0' option group 'fallback' option ip '8.8.8.8' - option port '853' - option type 'tls' + option type 'udp' config dns_servers + option enabled '0' + option group 'fallback' + option ip '8.8.4.4' option type 'udp' + +config dns_servers + option enabled '0' option group 'fallback' option ip '2001:4860:4860::8888' - option port '53' - option enabled '0' + option type 'udp' config dns_servers - option type 'udp' + option enabled '0' option group 'fallback' option ip '2001:4860:4860::8844' - option port '53' - option enabled '0' + option type 'udp' config dns_servers - option type 'udp' + option enabled '0' option group 'fallback' option ip '2001:da8::666' - option port '53' + option type 'udp' + +config dns_servers option enabled '0' + option group 'fallback' + option ip 'dns.quad9.net' + option type 'tls' config dns_servers + option enabled '0' option group 'fallback' - option type 'https' - option ip 'public.dns.iij.jp/dns-query' + option ip 'dns.google' + option type 'tls' + +config dns_servers option enabled '0' + option group 'fallback' + option ip '1.1.1.1' + option type 'tls' config dns_servers + option enabled '0' option group 'fallback' - option type 'https' - option ip 'jp.tiar.app/dns-query' + option ip 'jp.tiar.app' + option type 'tls' + +config dns_servers option enabled '0' + option group 'fallback' + option ip 'dot.tiar.app' + option type 'tls' config dns_servers + option enabled '0' option group 'fallback' + option ip 'dns.quad9.net/dns-query' option type 'https' - option ip 'jp.tiarap.org/dns-query' + +config dns_servers option enabled '0' + option group 'fallback' + option ip 'dns.google/dns-query' + option type 'https' config dns_servers + option enabled '0' option group 'fallback' - option ip 'jp.tiar.app' - option type 'tls' + option ip 'dns.cloudflare.com/dns-query' + option type 'https' + +config dns_servers option enabled '0' + option group 'fallback' + option ip '1.1.1.1/dns-query' + option type 'https' config dns_servers + option enabled '0' option group 'fallback' - option ip 'dot.tiar.app' - option type 'tls' + option ip 'public.dns.iij.jp/dns-query' + option type 'https' + +config dns_servers option enabled '0' + option group 'fallback' + option ip 'jp.tiar.app/dns-query' + option type 'https' + +config dns_servers + option enabled '0' + option group 'fallback' + option ip 'jp.tiarap.org/dns-query' + option type 'https' config dns_servers option enabled '0' @@ -245,5 +287,5 @@ config dns_servers config dns_servers option enabled '0' option group 'fallback' - option type 'https' option ip 'doh.mullvad.net/dns-query' + option type 'https' From 29109b338b3890179950eedb69955067a462e314 Mon Sep 17 00:00:00 2001 From: vernesong <42875168+vernesong@users.noreply.github.com> Date: Sun, 5 May 2024 20:43:45 +0800 Subject: [PATCH 30/36] chore: add cdn select window for download --- .../luasrc/controller/openclash.lua | 23 ++- .../luasrc/model/cbi/openclash/client.lua | 2 + .../model/cbi/openclash/config-overwrite.lua | 2 +- .../luasrc/model/cbi/openclash/settings.lua | 1 + .../luasrc/view/openclash/select_git_cdn.htm | 195 ++++++++++++++++++ .../luasrc/view/openclash/status.htm | 6 +- .../luasrc/view/openclash/update.htm | 48 ++++- .../po/zh-cn/openclash.zh-cn.po | 15 ++ .../root/usr/share/openclash/clash_version.sh | 3 + .../usr/share/openclash/openclash_core.sh | 18 +- .../usr/share/openclash/openclash_update.sh | 25 ++- .../usr/share/openclash/openclash_version.sh | 3 + 12 files changed, 306 insertions(+), 35 deletions(-) create mode 100644 luci-app-openclash/luasrc/view/openclash/select_git_cdn.htm diff --git a/luci-app-openclash/luasrc/controller/openclash.lua b/luci-app-openclash/luasrc/controller/openclash.lua index 2d993e38ff..d6e1cadf5e 100644 --- a/luci-app-openclash/luasrc/controller/openclash.lua +++ b/luci-app-openclash/luasrc/controller/openclash.lua @@ -345,21 +345,19 @@ local function historychecktime() end function core_download() - if uci:get("openclash", "config", "github_address_mod") == "0" or not uci:get("openclash", "config", "github_address_mod") then - uci:set("openclash", "config", "github_address_mod", "https://testingcf.jsdelivr.net/") - uci:commit("openclash") - luci.sys.call("rm -rf /tmp/clash_last_version 2>/dev/null && bash /usr/share/openclash/clash_version.sh >/dev/null 2>&1") - luci.sys.call("bash /usr/share/openclash/openclash_core.sh 'Dev' >/dev/null 2>&1 &") - luci.sys.call("bash /usr/share/openclash/openclash_core.sh 'TUN' >/dev/null 2>&1 &") - luci.sys.call("bash /usr/share/openclash/openclash_core.sh 'Meta' >/dev/null 2>&1 &") - uci:set("openclash", "config", "github_address_mod", "0") - uci:commit("openclash") + local cdn_url = luci.http.formvalue("url") + if cdn_url then + luci.sys.call(string.format("rm -rf /tmp/clash_last_version 2>/dev/null && bash /usr/share/openclash/clash_version.sh '%s' >/dev/null 2>&1", cdn_url)) + luci.sys.call(string.format("bash /usr/share/openclash/openclash_core.sh 'Dev' '%s' >/dev/null 2>&1 &", cdn_url)) + luci.sys.call(string.format("bash /usr/share/openclash/openclash_core.sh 'TUN' '%s' >/dev/null 2>&1 &", cdn_url)) + luci.sys.call(string.format("bash /usr/share/openclash/openclash_core.sh 'Meta' '%s' >/dev/null 2>&1 &", cdn_url)) else luci.sys.call("rm -rf /tmp/clash_last_version 2>/dev/null && bash /usr/share/openclash/clash_version.sh >/dev/null 2>&1") luci.sys.call("bash /usr/share/openclash/openclash_core.sh 'Dev' >/dev/null 2>&1 &") luci.sys.call("bash /usr/share/openclash/openclash_core.sh 'TUN' >/dev/null 2>&1 &") luci.sys.call("bash /usr/share/openclash/openclash_core.sh 'Meta' >/dev/null 2>&1 &") end + end function download_rule() @@ -410,7 +408,12 @@ function action_remove_all_core() end function action_one_key_update() - return luci.sys.call("rm -rf /tmp/*_last_version 2>/dev/null && bash /usr/share/openclash/openclash_update.sh 'one_key_update' >/dev/null 2>&1 &") + local cdn_url = luci.http.formvalue("url") + if cdn_url then + return luci.sys.call(string.format("rm -rf /tmp/*_last_version 2>/dev/null && bash /usr/share/openclash/openclash_update.sh 'one_key_update' '%s' >/dev/null 2>&1 &", cdn_url)) + else + return luci.sys.call("rm -rf /tmp/*_last_version 2>/dev/null && bash /usr/share/openclash/openclash_update.sh 'one_key_update' >/dev/null 2>&1 &") + end end local function dler_login_info_save() diff --git a/luci-app-openclash/luasrc/model/cbi/openclash/client.lua b/luci-app-openclash/luasrc/model/cbi/openclash/client.lua index 6394d6aa8f..f2d2b271f9 100644 --- a/luci-app-openclash/luasrc/model/cbi/openclash/client.lua +++ b/luci-app-openclash/luasrc/model/cbi/openclash/client.lua @@ -166,6 +166,8 @@ dler.reset = false dler.submit = false dler:section(SimpleSection).template = "openclash/dlercloud" +m:append(Template("openclash/select_git_cdn")) + if uci:get("openclash", "config", "dler_token") then return m, dler, form, s, ap, d else diff --git a/luci-app-openclash/luasrc/model/cbi/openclash/config-overwrite.lua b/luci-app-openclash/luasrc/model/cbi/openclash/config-overwrite.lua index 1e40e19d41..d555307229 100644 --- a/luci-app-openclash/luasrc/model/cbi/openclash/config-overwrite.lua +++ b/luci-app-openclash/luasrc/model/cbi/openclash/config-overwrite.lua @@ -69,7 +69,7 @@ o:value("http://captive.apple.com/generate_204") o.default = "0" o = s:taboption("settings", Value, "github_address_mod", translate("Github Address Modify")) -o.description = translate("Modify The Github Address In The Config And OpenClash With Proxy(CDN) To Prevent File Download Faild. Format Reference:").." ".."https://ghproxy.com/" +o.description = translate("Modify The Github Address In The Config And OpenClash With Proxy(CDN) To Prevent File Download Faild. Format Reference:").." ".."https://mirror.ghproxy.com/" o:value("0", translate("Disable")) o:value("https://fastly.jsdelivr.net/") o:value("https://testingcf.jsdelivr.net/") diff --git a/luci-app-openclash/luasrc/model/cbi/openclash/settings.lua b/luci-app-openclash/luasrc/model/cbi/openclash/settings.lua index 0e5c323dab..655b2dad4e 100644 --- a/luci-app-openclash/luasrc/model/cbi/openclash/settings.lua +++ b/luci-app-openclash/luasrc/model/cbi/openclash/settings.lua @@ -1297,6 +1297,7 @@ end m:append(Template("openclash/config_editor")) m:append(Template("openclash/toolbar_show")) +m:append(Template("openclash/select_git_cdn")) return m diff --git a/luci-app-openclash/luasrc/view/openclash/select_git_cdn.htm b/luci-app-openclash/luasrc/view/openclash/select_git_cdn.htm new file mode 100644 index 0000000000..8e5e1de187 --- /dev/null +++ b/luci-app-openclash/luasrc/view/openclash/select_git_cdn.htm @@ -0,0 +1,195 @@ + + + + + + + + + diff --git a/luci-app-openclash/luasrc/view/openclash/status.htm b/luci-app-openclash/luasrc/view/openclash/status.htm index 0c9288ab19..da96ccf9b5 100644 --- a/luci-app-openclash/luasrc/view/openclash/status.htm +++ b/luci-app-openclash/luasrc/view/openclash/status.htm @@ -997,11 +997,7 @@ { var r = confirm("<%:You have not installed the core yet, do you want to download and install it now?%>") if (r == true) { - XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "core_download")%>', null, function(x, status) { - if ( x && x.status == 200 ) { - window.location.href='<%="'+window.location.protocol+'//'+window.location.hostname+'/cgi-bin/luci/admin/services/openclash/log"%>'; - } - }); + return select_git_cdn(core_download); } } } diff --git a/luci-app-openclash/luasrc/view/openclash/update.htm b/luci-app-openclash/luasrc/view/openclash/update.htm index 803356389f..53e2f602b2 100644 --- a/luci-app-openclash/luasrc/view/openclash/update.htm +++ b/luci-app-openclash/luasrc/view/openclash/update.htm @@ -84,6 +84,11 @@ <%:Collecting data...%>

+ +

+ <%:Collecting data...%> +

+

<%:Collecting data...%> @@ -153,20 +158,21 @@ var core_meta_up = document.getElementById('core_meta_up'); var op_up = document.getElementById('op_up'); var update_tip = document.getElementById('update_tip'); - var ma_core_up = document.getElementById('ma_core_up'); - var ma_core_tun_up = document.getElementById('ma_core_tun_up'); - var ma_core_meta_up = document.getElementById('ma_core_meta_up'); - var ma_op_up = document.getElementById('ma_op_up'); - var restore = document.getElementById('restore'); - var backup = document.getElementById('backup'); - var backup_ex_core = document.getElementById('backup_ex_core'); + var ma_core_up = document.getElementById('ma_core_up'); + var ma_core_tun_up = document.getElementById('ma_core_tun_up'); + var ma_core_meta_up = document.getElementById('ma_core_meta_up'); + var ma_op_up = document.getElementById('ma_op_up'); + var restore = document.getElementById('restore'); + var backup = document.getElementById('backup'); + var backup_ex_core = document.getElementById('backup_ex_core'); var backup_core_only = document.getElementById('backup_core_only'); var backup_config_only = document.getElementById('backup_config_only'); var backup_rule_only = document.getElementById('backup_rule_only'); var backup_proxy_only = document.getElementById('backup_proxy_only'); - var one_key_update = document.getElementById('one_key_update'); - var remove_core = document.getElementById('remove_core'); - var release_branch = document.getElementById('RELEASE_BRANCH'); + var one_key_update = document.getElementById('one_key_update'); + var one_key_update_cdn = document.getElementById('one_key_update_cdn'); + var remove_core = document.getElementById('remove_core'); + var release_branch = document.getElementById('RELEASE_BRANCH'); core_up.innerHTML = ''; core_tun_up.innerHTML = ''; core_meta_up.innerHTML = ''; @@ -177,6 +183,7 @@ ma_op_up.innerHTML = ''; restore.innerHTML = ''; one_key_update.innerHTML = ''; + one_key_update_cdn.innerHTML = ''; remove_core.innerHTML = ''; backup.innerHTML = ''; backup_ex_core.innerHTML = ''; @@ -543,4 +550,25 @@ }); } + function all_one_key_update_cdn(btn) + { + var v = core_version.value; + var r = release_branch.value; + XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "save_corever_branch")%>', {core_ver: v, release_branch: r}, function(x, status) { + if (x && x.status == 200) { + btn.value = '<%:One Click Check Update With CDN%>'; + btn.disabled = true; + var r = confirm("<%:Check and Update all Cores and OpenClash?%>") + if (r == true) { + btn.disabled = false; + return select_git_cdn(one_key_update); + } + else { + btn.disabled = false; + return false; + } + } + }); + } + //]]> 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 0bc3334e1e..792a0429e5 100644 --- a/luci-app-openclash/po/zh-cn/openclash.zh-cn.po +++ b/luci-app-openclash/po/zh-cn/openclash.zh-cn.po @@ -1419,6 +1419,9 @@ msgstr "还原默认配置" msgid "One Click Check Update" msgstr "一键检查更新" +msgid "One Click Check Update With CDN" +msgstr "使用CDN一键检查更新" + msgid "Failed to get the latest version. Please try again later!" msgstr "最新版本获取失败,请稍后再试!" @@ -3524,3 +3527,15 @@ msgstr "绕过服务器地址,防止重复代理" msgid "Warning: Unsupported format, Proxies Address Skip Function Ignore Proxy-providers File" msgstr "警告:不支持的格式,绕过代理服务器地址功能已忽略代理集文件" + +msgid "Choose CDN For Downloading:" +msgstr "请在下方选择一个 CDN 地址进行加速下载:" + +msgid "Custom Your CDN URL" +msgstr "自定义链接地址" + +msgid "Type CDN URL, Format Like" +msgstr "输入链接地址,格式请参考" + +msgid "Please enter a valid URL!" +msgstr "请参考示例输入正确的链接地址!" \ No newline at end of file diff --git a/luci-app-openclash/root/usr/share/openclash/clash_version.sh b/luci-app-openclash/root/usr/share/openclash/clash_version.sh index bb74e8528f..a855ccbb75 100644 --- a/luci-app-openclash/root/usr/share/openclash/clash_version.sh +++ b/luci-app-openclash/root/usr/share/openclash/clash_version.sh @@ -15,6 +15,9 @@ CHTIME=$(date "+%Y-%m-%d-%H" -r "/tmp/clash_last_version" 2>/dev/null) LAST_OPVER="/tmp/clash_last_version" RELEASE_BRANCH=$(uci -q get openclash.config.release_branch || echo "master") github_address_mod=$(uci -q get openclash.config.github_address_mod || echo 0) +if [ -n "$1" ]; then + github_address_mod="$1" +fi LOG_FILE="/tmp/openclash.log" set_lock diff --git a/luci-app-openclash/root/usr/share/openclash/openclash_core.sh b/luci-app-openclash/root/usr/share/openclash/openclash_core.sh index 0d925f72ef..883a436e25 100644 --- a/luci-app-openclash/root/usr/share/openclash/openclash_core.sh +++ b/luci-app-openclash/root/usr/share/openclash/openclash_core.sh @@ -4,18 +4,28 @@ . /usr/share/openclash/log.sh github_address_mod=$(uci -q get openclash.config.github_address_mod || echo 0) -if [ "$github_address_mod" = "0" ] && [ "$1" != "one_key_update" ] && [ "$2" != "one_key_update" ]; then +if [ "$github_address_mod" = "0" ] && [ -z "$(echo $2 2>/dev/null |grep -E 'http|one_key_update')" ] && [ -z "$(echo $3 2>/dev/null |grep 'http')" ]; then LOG_OUT "Tip: If the download fails, try setting the CDN in Overwrite Settings - General Settings - Github Address Modify Options" fi +if [ -n "$3" ] && [ "$2" = "one_key_update" ]; then + github_address_mod="$3" +fi +if [ -n "$2" ] && [ "$2" != "one_key_update" ]; then + github_address_mod="$2" +fi CORE_TYPE="$1" C_CORE_TYPE=$(uci -q get openclash.config.core_type) -[ -z "$CORE_TYPE" ] || [ "$1" = "one_key_update" ] && CORE_TYPE="Dev" +[ -z "$CORE_TYPE" ] && CORE_TYPE="Dev" small_flash_memory=$(uci -q get openclash.config.small_flash_memory) CPU_MODEL=$(uci -q get openclash.config.core_version) RELEASE_BRANCH=$(uci -q get openclash.config.release_branch || echo "master") LOG_FILE="/tmp/openclash.log" -[ ! -f "/tmp/clash_last_version" ] && /usr/share/openclash/clash_version.sh 2>/dev/null +if [ "$github_address_mod" != "0" ]; then + [ ! -f "/tmp/clash_last_version" ] && /usr/share/openclash/clash_version.sh "$github_address_mod" 2>/dev/null +else + [ ! -f "/tmp/clash_last_version" ] && /usr/share/openclash/clash_version.sh 2>/dev/null +fi if [ ! -f "/tmp/clash_last_version" ]; then LOG_OUT "Error: 【"$CORE_TYPE"】Core Version Check Error, Please Try Again Later..." SLOG_CLEAN @@ -176,7 +186,7 @@ if [ "$CORE_CV" != "$CORE_LV" ] || [ -z "$CORE_CV" ]; then if [ "$if_restart" -eq 1 ]; then uci -q set openclash.config.config_reload=0 uci -q commit openclash - if [ -z "$2" ] && [ "$1" != "one_key_update" ] && [ "$(find /tmp/lock/ |grep -v "openclash.lock" |grep -c "openclash")" -le 1 ] && [ "$(unify_ps_prevent)" -eq 0 ]; then + if ([ -z "$2" ] || ([ -n "$2" ] && [ "$2" != "one_key_update" ])) && [ "$(find /tmp/lock/ |grep -v "openclash.lock" |grep -c "openclash")" -le 1 ] && [ "$(unify_ps_prevent)" -eq 0 ]; then /etc/init.d/openclash restart >/dev/null 2>&1 & fi else diff --git a/luci-app-openclash/root/usr/share/openclash/openclash_update.sh b/luci-app-openclash/root/usr/share/openclash/openclash_update.sh index 3f0383e514..f4f707635d 100644 --- a/luci-app-openclash/root/usr/share/openclash/openclash_update.sh +++ b/luci-app-openclash/root/usr/share/openclash/openclash_update.sh @@ -11,7 +11,14 @@ del_lock() { rm -rf "/tmp/lock/openclash_update.lock" } -[ ! -f "/tmp/openclash_last_version" ] && /usr/share/openclash/openclash_version.sh 2>/dev/null +if [ -n "$1" ] && [ "$1" != "one_key_update" ]; then + [ ! -f "/tmp/openclash_last_version" ] && /usr/share/openclash/openclash_version.sh "$1" 2>/dev/null +elif [ -n "$2" ]; then + [ ! -f "/tmp/openclash_last_version" ] && /usr/share/openclash/openclash_version.sh "$2" 2>/dev/null +else + [ ! -f "/tmp/openclash_last_version" ] && /usr/share/openclash/openclash_version.sh 2>/dev/null +fi + if [ ! -f "/tmp/openclash_last_version" ]; then LOG_OUT "Error: Failed to Get Version Information, Please Try Again Later..." SLOG_CLEAN @@ -30,12 +37,20 @@ github_address_mod=$(uci -q get openclash.config.github_address_mod || echo 0) if [ "$1" = "one_key_update" ]; then uci -q set openclash.config.enable=1 uci -q commit openclash - if [ "$github_address_mod" = "0" ]; then + if [ "$github_address_mod" = "0" ] && [ -z "$2" ]; then LOG_OUT "Tip: If the download fails, try setting the CDN in Overwrite Settings - General Settings - Github Address Modify Options" fi - /usr/share/openclash/openclash_core.sh "$1" >/dev/null 2>&1 & - /usr/share/openclash/openclash_core.sh "TUN" "$1" >/dev/null 2>&1 & - /usr/share/openclash/openclash_core.sh "Meta" "$1" >/dev/null 2>&1 & + if [ -n "$2" ]; then + /usr/share/openclash/openclash_core.sh "Dev" "$1" "$2" >/dev/null 2>&1 & + /usr/share/openclash/openclash_core.sh "TUN" "$1" "$2" >/dev/null 2>&1 & + /usr/share/openclash/openclash_core.sh "Meta" "$1" "$2" >/dev/null 2>&1 & + github_address_mod="$2" + else + /usr/share/openclash/openclash_core.sh "Dev" "$1" >/dev/null 2>&1 & + /usr/share/openclash/openclash_core.sh "TUN" "$1" >/dev/null 2>&1 & + /usr/share/openclash/openclash_core.sh "Meta" "$1" >/dev/null 2>&1 & + fi + wait else if [ "$github_address_mod" = "0" ]; then diff --git a/luci-app-openclash/root/usr/share/openclash/openclash_version.sh b/luci-app-openclash/root/usr/share/openclash/openclash_version.sh index faace5b6a8..163559af7c 100644 --- a/luci-app-openclash/root/usr/share/openclash/openclash_version.sh +++ b/luci-app-openclash/root/usr/share/openclash/openclash_version.sh @@ -7,6 +7,9 @@ RELEASE_BRANCH=$(uci -q get openclash.config.release_branch || echo "master") OP_CV=$(rm -f /var/lock/opkg.lock && opkg status luci-app-openclash 2>/dev/null |grep 'Version' |awk -F '-' '{print $1}' |awk -F 'Version: ' '{print $2}' |awk -F '.' '{print $2$3}' 2>/dev/null) OP_LV=$(sed -n 1p $LAST_OPVER 2>/dev/null |awk -F '-' '{print $1}' |awk -F 'v' '{print $2}' |awk -F '.' '{print $2$3}' 2>/dev/null) github_address_mod=$(uci -q get openclash.config.github_address_mod || echo 0) +if [ -n "$1" ]; then + github_address_mod="$1" +fi LOG_FILE="/tmp/openclash.log" if [ "$TIME" != "$CHTIME" ]; then From 57a4db538e6f10f9d6e531924619bb31e6dab306 Mon Sep 17 00:00:00 2001 From: vernesong <42875168+vernesong@users.noreply.github.com> Date: Sun, 5 May 2024 20:44:47 +0800 Subject: [PATCH 31/36] 0.46.009 --- luci-app-openclash/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/luci-app-openclash/Makefile b/luci-app-openclash/Makefile index ce5b9cc3b4..b52b55181e 100644 --- a/luci-app-openclash/Makefile +++ b/luci-app-openclash/Makefile @@ -1,7 +1,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-openclash -PKG_VERSION:=0.46.008 +PKG_VERSION:=0.46.009 PKG_RELEASE:=beta PKG_MAINTAINER:=vernesong From c5fbc16104af3e70a450a1c81c527e7a6f79cc22 Mon Sep 17 00:00:00 2001 From: vernesong <42875168+vernesong@users.noreply.github.com> Date: Sun, 5 May 2024 21:01:27 +0800 Subject: [PATCH 32/36] fix typo --- luci-app-openclash/luasrc/view/openclash/status.htm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/luci-app-openclash/luasrc/view/openclash/status.htm b/luci-app-openclash/luasrc/view/openclash/status.htm index da96ccf9b5..4f4cca596d 100644 --- a/luci-app-openclash/luasrc/view/openclash/status.htm +++ b/luci-app-openclash/luasrc/view/openclash/status.htm @@ -997,7 +997,7 @@ { var r = confirm("<%:You have not installed the core yet, do you want to download and install it now?%>") if (r == true) { - return select_git_cdn(core_download); + return select_git_cdn("core_download"); } } } From 346d82d2026befa7151bc6d8c6decf34e75895d8 Mon Sep 17 00:00:00 2001 From: vernesong <42875168+vernesong@users.noreply.github.com> Date: Sun, 5 May 2024 21:01:46 +0800 Subject: [PATCH 33/36] fix typo --- luci-app-openclash/luasrc/view/openclash/update.htm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/luci-app-openclash/luasrc/view/openclash/update.htm b/luci-app-openclash/luasrc/view/openclash/update.htm index 53e2f602b2..623051b835 100644 --- a/luci-app-openclash/luasrc/view/openclash/update.htm +++ b/luci-app-openclash/luasrc/view/openclash/update.htm @@ -561,7 +561,7 @@ var r = confirm("<%:Check and Update all Cores and OpenClash?%>") if (r == true) { btn.disabled = false; - return select_git_cdn(one_key_update); + return select_git_cdn("one_key_update"); } else { btn.disabled = false; From 062ddd155c967270b6d3d6db0b8a4a368d925125 Mon Sep 17 00:00:00 2001 From: vernesong <42875168+vernesong@users.noreply.github.com> Date: Sun, 5 May 2024 21:02:28 +0800 Subject: [PATCH 34/36] 0.46.010 --- luci-app-openclash/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/luci-app-openclash/Makefile b/luci-app-openclash/Makefile index b52b55181e..8d4d01d366 100644 --- a/luci-app-openclash/Makefile +++ b/luci-app-openclash/Makefile @@ -1,7 +1,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-openclash -PKG_VERSION:=0.46.009 +PKG_VERSION:=0.46.010 PKG_RELEASE:=beta PKG_MAINTAINER:=vernesong From 80146d1be6425b639e8353dd950b75786c5bc12e Mon Sep 17 00:00:00 2001 From: vernesong <42875168+vernesong@users.noreply.github.com> Date: Sat, 18 May 2024 19:13:29 +0800 Subject: [PATCH 35/36] chore: refine --- .../luasrc/controller/openclash.lua | 8 ++- .../model/cbi/openclash/config-overwrite.lua | 15 ++++- .../luasrc/model/cbi/openclash/settings.lua | 31 +++++++++- .../po/zh-cn/openclash.zh-cn.po | 14 ++++- luci-app-openclash/root/etc/init.d/openclash | 62 +++++++++++++++++-- .../usr/share/openclash/openclash_debug.sh | 7 ++- .../share/openclash/openclash_debug_dns.lua | 9 ++- .../openclash/openclash_debug_getcon.lua | 9 ++- .../share/openclash/openclash_history_get.sh | 7 ++- 9 files changed, 145 insertions(+), 17 deletions(-) diff --git a/luci-app-openclash/luasrc/controller/openclash.lua b/luci-app-openclash/luasrc/controller/openclash.lua index d6e1cadf5e..b91045af26 100644 --- a/luci-app-openclash/luasrc/controller/openclash.lua +++ b/luci-app-openclash/luasrc/controller/openclash.lua @@ -175,7 +175,13 @@ local function chnroutev6() end local function daip() - local daip = luci.sys.exec("uci -q get network.lan.ipaddr |awk -F '/' '{print $1}' 2>/dev/null |tr -d '\n'") + local daip, lan_int_name + lan_int_name = uci:get("openclash", "config", "lan_interface_name") or "0" + if lan_int_name == "0" then + daip = luci.sys.exec("uci -q get network.lan.ipaddr |awk -F '/' '{print $1}' 2>/dev/null |tr -d '\n'") + else + daip = luci.sys.exec(string.format("ip address show %s | grep -w 'inet' 2>/dev/null |grep -Eo 'inet [0-9\.]+' | awk '{print $2}' | tr -d '\n'", lan_int_name)) + end if not daip or daip == "" then daip = luci.sys.exec("ip address show $(uci -q -p /tmp/state get network.lan.ifname || uci -q -p /tmp/state get network.lan.device) | grep -w 'inet' 2>/dev/null |grep -Eo 'inet [0-9\.]+' | awk '{print $2}' | tr -d '\n'") end diff --git a/luci-app-openclash/luasrc/model/cbi/openclash/config-overwrite.lua b/luci-app-openclash/luasrc/model/cbi/openclash/config-overwrite.lua index d555307229..cefa0d4229 100644 --- a/luci-app-openclash/luasrc/model/cbi/openclash/config-overwrite.lua +++ b/luci-app-openclash/luasrc/model/cbi/openclash/config-overwrite.lua @@ -17,8 +17,19 @@ bold_off = [[]] local op_mode = string.sub(luci.sys.exec('uci get openclash.config.operation_mode 2>/dev/null'),0,-2) if not op_mode then op_mode = "redir-host" end -local lan_ip = SYS.exec("uci -q get network.lan.ipaddr |awk -F '/' '{print $1}' 2>/dev/null |tr -d '\n' || ip address show $(uci -q -p /tmp/state get network.lan.ifname || uci -q -p /tmp/state get network.lan.device) | grep -w 'inet' 2>/dev/null |grep -Eo 'inet [0-9\.]+' | awk '{print $2}' | tr -d '\n' || ip addr show 2>/dev/null | grep -w 'inet' | grep 'global' | grep 'brd' | grep -Eo 'inet [0-9\.]+' | awk '{print $2}' | head -n 1 | tr -d '\n'") - +local lan_int_name = uci:get("openclash", "config", "lan_interface_name") or "0" +local lan_ip +if lan_int_name == "0" then + lan_ip = SYS.exec("uci -q get network.lan.ipaddr |awk -F '/' '{print $1}' 2>/dev/null |tr -d '\n'") +else + lan_ip = SYS.exec(string.format("ip address show %s | grep -w 'inet' 2>/dev/null |grep -Eo 'inet [0-9\.]+' | awk '{print $2}' | tr -d '\n'", lan_int_name)) +end +if not lan_ip or lan_ip == "" then + lan_ip = luci.sys.exec("ip address show $(uci -q -p /tmp/state get network.lan.ifname || uci -q -p /tmp/state get network.lan.device) | grep -w 'inet' 2>/dev/null |grep -Eo 'inet [0-9\.]+' | awk '{print $2}' | tr -d '\n'") +end +if not lan_ip or lan_ip == "" then + lan_ip = luci.sys.exec("ip addr show 2>/dev/null | grep -w 'inet' | grep 'global' | grep 'brd' | grep -Eo 'inet [0-9\.]+' | awk '{print $2}' | head -n 1 | tr -d '\n'") +end m = Map("openclash", translate("Overwrite Settings")) m.pageaction = false m.description = translate("Note: To restore the default configuration, try accessing:").." http://"..lan_ip.."/cgi-bin/luci/admin/services/openclash/restore" diff --git a/luci-app-openclash/luasrc/model/cbi/openclash/settings.lua b/luci-app-openclash/luasrc/model/cbi/openclash/settings.lua index 655b2dad4e..43e17fd4f8 100644 --- a/luci-app-openclash/luasrc/model/cbi/openclash/settings.lua +++ b/luci-app-openclash/luasrc/model/cbi/openclash/settings.lua @@ -16,8 +16,19 @@ bold_off = [[]] local op_mode = string.sub(luci.sys.exec('uci get openclash.config.operation_mode 2>/dev/null'),0,-2) if not op_mode then op_mode = "redir-host" end -local lan_ip = SYS.exec("uci -q get network.lan.ipaddr |awk -F '/' '{print $1}' 2>/dev/null |tr -d '\n' || ip address show $(uci -q -p /tmp/state get network.lan.ifname || uci -q -p /tmp/state get network.lan.device) | grep -w 'inet' 2>/dev/null |grep -Eo 'inet [0-9\.]+' | awk '{print $2}' | tr -d '\n' || ip addr show 2>/dev/null | grep -w 'inet' | grep 'global' | grep 'brd' | grep -Eo 'inet [0-9\.]+' | awk '{print $2}' | head -n 1 | tr -d '\n'") - +local lan_int_name = uci:get("openclash", "config", "lan_interface_name") or "0" +local lan_ip +if lan_int_name == "0" then + lan_ip = SYS.exec("uci -q get network.lan.ipaddr |awk -F '/' '{print $1}' 2>/dev/null |tr -d '\n'") +else + lan_ip = SYS.exec(string.format("ip address show %s | grep -w 'inet' 2>/dev/null |grep -Eo 'inet [0-9\.]+' | awk '{print $2}' | tr -d '\n'", lan_int_name)) +end +if not lan_ip or lan_ip == "" then + lan_ip = luci.sys.exec("ip address show $(uci -q -p /tmp/state get network.lan.ifname || uci -q -p /tmp/state get network.lan.device) | grep -w 'inet' 2>/dev/null |grep -Eo 'inet [0-9\.]+' | awk '{print $2}' | tr -d '\n'") +end +if not lan_ip or lan_ip == "" then + lan_ip = luci.sys.exec("ip addr show 2>/dev/null | grep -w 'inet' | grep 'global' | grep 'brd' | grep -Eo 'inet [0-9\.]+' | awk '{print $2}' | head -n 1 | tr -d '\n'") +end m = Map("openclash", translate("Plugin Settings")) m.pageaction = false m.description = translate("Note: To restore the default configuration, try accessing:").." http://"..lan_ip.."/cgi-bin/luci/admin/services/openclash/restore".. @@ -272,6 +283,22 @@ o = s:taboption("traffic_control", Flag, "intranet_allowed", translate("Only int o.description = translate("When Enabled, The Control Panel And The Connection Broker Port Will Not Be Accessible From The Public Network") o.default = 1 +o = s:taboption("traffic_control", DynamicList, "intranet_allowed_wan_name", translate("WAN Interface Name")) +o.description = translate("Select WAN Interface Name For The Intranet Allowed") +o:depends("intranet_allowed", "1") +local interfaces = SYS.exec("ls -l /sys/class/net/ 2>/dev/null |awk '{print $9}' 2>/dev/null") +for interface in string.gmatch(interfaces, "%S+") do + o:value(interface) +end + +o = s:taboption("traffic_control", ListValue, "lan_interface_name", translate("LAN Interface Name")) +o.description = translate("Select LAN Interface Name") +o:value("0", translate("Disable")) +o.default = "0" +for interface in string.gmatch(interfaces, "%S+") do + o:value(interface) +end + o = s:taboption("traffic_control", Value, "local_network_pass", translate("Local IPv4 Network Bypassed List")) o.template = "cbi/tvalue" o.description = translate("The Traffic of The Destination For The Specified Address Will Not Pass The Core") 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 792a0429e5..7feecee524 100644 --- a/luci-app-openclash/po/zh-cn/openclash.zh-cn.po +++ b/luci-app-openclash/po/zh-cn/openclash.zh-cn.po @@ -3538,4 +3538,16 @@ msgid "Type CDN URL, Format Like" msgstr "输入链接地址,格式请参考" msgid "Please enter a valid URL!" -msgstr "请参考示例输入正确的链接地址!" \ No newline at end of file +msgstr "请参考示例输入正确的链接地址!" + +msgid "WAN Interface Name" +msgstr "WAN 接口名称" + +msgid "Select WAN Interface Name For The Intranet Allowed" +msgstr "为仅允许内网指定正确的 WAN 接口名称" + +msgid "LAN Interface Name" +msgstr "LAN 接口名称" + +msgid "Select LAN Interface Name" +msgstr "指定正确的 LAN 接口名称" \ No newline at end of file diff --git a/luci-app-openclash/root/etc/init.d/openclash b/luci-app-openclash/root/etc/init.d/openclash index 7f53fadd56..45a30435f9 100644 --- a/luci-app-openclash/root/etc/init.d/openclash +++ b/luci-app-openclash/root/etc/init.d/openclash @@ -935,6 +935,32 @@ ac_add() [ -n "$3" ] && ipset add "$3" "$1" 2>/dev/null } +wan_name_add() +{ + if [ -z "$1" ]; then + return + fi + + if [ -n "$wan_ints" ]; then + wan_ints="$wan_ints $1" + else + wan_ints="$1" + fi +} + +wan6_name_add() +{ + if [ -z "$1" ]; then + return + fi + + if [ -n "$wan6_ints" ]; then + wan6_ints="$wan6_ints $1" + else + wan6_ints="$1" + fi +} + upnp_exclude() { if [ -s "$upnp_lease_file" ]; then @@ -1526,7 +1552,12 @@ if [ -n "$FW4" ]; then #intranet allowed if [ "$intranet_allowed" -eq 1 ]; then - wan_ints=$(nft list chain inet fw4 input |grep -e "jump input_wan" 2>/dev/null |awk '{for (i=1;i<=NF;i++){if ($i ~ /iifname/ && $(i+1) != "{") {print $(i+1)} if ($i ~ /iifname/ && $(i+1) == "{"){for (j=i+1;j<=NF;j++){if ($j~ /}/) {out="";for (k=i+1;k<=j;k++){out=out" "$k};print out}}}}}' 2>/dev/null |sed 's/"//g'|sed 's/{//g'|sed 's/}//g'|sed 's/,//g') + if [ -n "$intranet_allowed_wan_name" ]; then + config_load "openclash" + config_list_foreach "config" "intranet_allowed_wan_name" wan_name_add + else + wan_ints=$(nft list chain inet fw4 input |grep -e "jump input_wan" 2>/dev/null |awk '{for (i=1;i<=NF;i++){if ($i ~ /iifname/ && $(i+1) != "{") {print $(i+1)} if ($i ~ /iifname/ && $(i+1) == "{"){for (j=i+1;j<=NF;j++){if ($j~ /}/) {out="";for (k=i+1;k<=j;k++){out=out" "$k};print out}}}}}' 2>/dev/null |sed 's/"//g'|sed 's/{//g'|sed 's/}//g'|sed 's/,//g') + fi if [ -n "$wan_ints" ]; then nft 'add chain inet fw4 openclash_wan_input' nft 'flush chain inet fw4 openclash_wan_input' @@ -2174,7 +2205,12 @@ if [ -n "$FW4" ]; then #intranet allowed if [ "$intranet_allowed" -eq 1 ]; then - wan6_ints=$(nft list chain inet fw4 input |grep -e "jump input_wan" 2>/dev/null |awk '{for (i=1;i<=NF;i++){if ($i ~ /iifname/ && $(i+1) != "{") {print $(i+1)} if ($i ~ /iifname/ && $(i+1) == "{"){for (j=i+1;j<=NF;j++){if ($j~ /}/) {out="";for (k=i+1;k<=j;k++){out=out" "$k};print out}}}}}' 2>/dev/null |sed 's/"//g'|sed 's/{//g'|sed 's/}//g'|sed 's/,//g') + if [ -n "$intranet_allowed_wan_name" ]; then + config_load "openclash" + config_list_foreach "config" "intranet_allowed_wan_name" wan6_name_add + else + wan6_ints=$(nft list chain inet fw4 input |grep -e "jump input_wan" 2>/dev/null |awk '{for (i=1;i<=NF;i++){if ($i ~ /iifname/ && $(i+1) != "{") {print $(i+1)} if ($i ~ /iifname/ && $(i+1) == "{"){for (j=i+1;j<=NF;j++){if ($j~ /}/) {out="";for (k=i+1;k<=j;k++){out=out" "$k};print out}}}}}' 2>/dev/null |sed 's/"//g'|sed 's/{//g'|sed 's/}//g'|sed 's/,//g') + fi if [ -n "$wan6_ints" ]; then nft 'add chain inet fw4 openclash_wan6_input' nft 'flush chain inet fw4 openclash_wan6_input' @@ -2294,7 +2330,12 @@ if [ -z "$FW4" ]; then #intranet allowed if [ "$intranet_allowed" -eq 1 ]; then - wan_ints=$(iptables-save -t filter |grep -e "-j zone_wan_input" 2>/dev/null |awk '{for (i=1;i<=NF;i++) {if ($i ~ /-i/) {print $(i+1)}}}' 2>/dev/null) + if [ -n "$intranet_allowed_wan_name" ]; then + config_load "openclash" + config_list_foreach "config" "intranet_allowed_wan_name" wan_name_add + else + wan_ints=$(iptables-save -t filter |grep -e "-j zone_wan_input" 2>/dev/null |awk '{for (i=1;i<=NF;i++) {if ($i ~ /-i/) {print $(i+1)}}}' 2>/dev/null) + fi if [ -n "$wan_ints" ]; then iptables -t filter -N openclash_wan_input iptables -t filter -F openclash_wan_input @@ -2952,7 +2993,12 @@ if [ -z "$FW4" ]; then #intranet allowed if [ "$intranet_allowed" -eq 1 ]; then - wan6_ints=$(ip6tables-save -t filter |grep -e "-j zone_wan_input" 2>/dev/null |awk '{for (i=1;i<=NF;i++) {if ($i ~ /-i/) {print $(i+1)}}}' 2>/dev/null) + if [ -n "$intranet_allowed_wan_name" ]; then + config_load "openclash" + config_list_foreach "config" "intranet_allowed_wan_name" wan6_name_add + else + wan6_ints=$(ip6tables-save -t filter |grep -e "-j zone_wan_input" 2>/dev/null |awk '{for (i=1;i<=NF;i++) {if ($i ~ /-i/) {print $(i+1)}}}' 2>/dev/null) + fi if [ -n "$wan6_ints" ]; then ip6tables -t filter -N openclash_wan_input ip6tables -t filter -F openclash_wan_input @@ -3092,7 +3138,12 @@ get_config() fakeip_range=$(uci -q get openclash.config.fakeip_range) fi [ -z "$fakeip_range" ] && fakeip_range="198.18.0.1/16" - lan_ip=$(uci -q get network.lan.ipaddr |awk -F '/' '{print $1}' 2>/dev/null || ip address show $(uci -q -p /tmp/state get network.lan.ifname || uci -q -p /tmp/state get network.lan.device) | grep -w "inet" 2>/dev/null |grep -Eo 'inet [0-9\.]+' | awk '{print $2}' || ip addr show 2>/dev/null | grep -w 'inet' | grep 'global' | grep 'brd' | grep -Eo 'inet [0-9\.]+' | awk '{print $2}' | head -n 1) + lan_interface_name=$(uci -q get openclash.config.lan_interface_name || echo "0") + if [ "$lan_interface_name" = "0" ]; then + lan_ip=$(uci -q get network.lan.ipaddr |awk -F '/' '{print $1}' 2>/dev/null || ip address show $(uci -q -p /tmp/state get network.lan.ifname || uci -q -p /tmp/state get network.lan.device) | grep -w "inet" 2>/dev/null |grep -Eo 'inet [0-9\.]+' | awk '{print $2}' || ip addr show 2>/dev/null | grep -w 'inet' | grep 'global' | grep 'brd' | grep -Eo 'inet [0-9\.]+' | awk '{print $2}' | head -n 1) + else + lan_ip=$(ip address show $(uci -q -p $lan_interface_name) | grep -w "inet" 2>/dev/null |grep -Eo 'inet [0-9\.]+' | awk '{print $2}') + fi wan_ip4s=$(/usr/share/openclash/openclash_get_network.lua "wanip" 2>/dev/null) wan_ip6s=$(ifconfig | grep 'inet6 addr' | awk '{print $3}' 2>/dev/null) disable_masq_cache=$(uci -q get openclash.config.disable_masq_cache) @@ -3132,6 +3183,7 @@ get_config() enable_unified_delay=$(uci -q get openclash.config.enable_unified_delay || echo "0") keep_alive_interval=$(uci -q get openclash.config.keep_alive_interval || echo "0") proxy_dns_group=$(uci -q get openclash.config.proxy_dns_group || echo "Disable") + intranet_allowed_wan_name=$(uci -q get openclash.config.intranet_allowed_wan_name || echo "0") [ -z "$dns_port" ] && dns_port=7874 && uci -q set openclash.config.dns_port=7874 uci -q set openclash.config.restricted_mode=0 && uci -q commit openclash } diff --git a/luci-app-openclash/root/usr/share/openclash/openclash_debug.sh b/luci-app-openclash/root/usr/share/openclash/openclash_debug.sh index 1de7acca93..f6079ad677 100644 --- a/luci-app-openclash/root/usr/share/openclash/openclash_debug.sh +++ b/luci-app-openclash/root/usr/share/openclash/openclash_debug.sh @@ -45,7 +45,12 @@ router_self_proxy=$(uci -q get openclash.config.router_self_proxy) core_type=$(uci -q get openclash.config.core_type || echo "Dev") da_password=$(uci -q get openclash.config.dashboard_password) cn_port=$(uci -q get openclash.config.cn_port) -lan_ip=$(uci -q get network.lan.ipaddr |awk -F '/' '{print $1}' 2>/dev/null || ip address show $(uci -q -p /tmp/state get network.lan.ifname || uci -q -p /tmp/state get network.lan.device) | grep -w "inet" 2>/dev/null |grep -Eo 'inet [0-9\.]+' | awk '{print $2}' || ip addr show 2>/dev/null | grep -w 'inet' | grep 'global' | grep 'brd' | grep -Eo 'inet [0-9\.]+' | awk '{print $2}' | head -n 1) +lan_interface_name=$(uci -q get openclash.config.lan_interface_name || echo "0") +if [ "$lan_interface_name" = "0" ]; then + lan_ip=$(uci -q get network.lan.ipaddr |awk -F '/' '{print $1}' 2>/dev/null || ip address show $(uci -q -p /tmp/state get network.lan.ifname || uci -q -p /tmp/state get network.lan.device) | grep -w "inet" 2>/dev/null |grep -Eo 'inet [0-9\.]+' | awk '{print $2}' || ip addr show 2>/dev/null | grep -w 'inet' | grep 'global' | grep 'brd' | grep -Eo 'inet [0-9\.]+' | awk '{print $2}' | head -n 1) +else + lan_ip=$(ip address show $(uci -q -p $lan_interface_name) | grep -w "inet" 2>/dev/null |grep -Eo 'inet [0-9\.]+' | awk '{print $2}') +fi dnsmasq_default_resolvfile=$(uci -q get openclash.config.default_resolvfile) if [ -z "$RAW_CONFIG_FILE" ] || [ ! -f "$RAW_CONFIG_FILE" ]; then diff --git a/luci-app-openclash/root/usr/share/openclash/openclash_debug_dns.lua b/luci-app-openclash/root/usr/share/openclash/openclash_debug_dns.lua index 59064af318..8c91fa8d65 100644 --- a/luci-app-openclash/root/usr/share/openclash/openclash_debug_dns.lua +++ b/luci-app-openclash/root/usr/share/openclash/openclash_debug_dns.lua @@ -10,8 +10,13 @@ local addr = arg[1] local resolve = arg[2] local function debug_dns() - local info, ip, host - ip = luci.sys.exec("uci -q get network.lan.ipaddr |awk -F '/' '{print $1}' 2>/dev/null |tr -d '\n'") + local info, ip, host, lan_int_name + lan_int_name = uci:get("openclash", "config", "lan_interface_name") or "0" + if lan_int_name == "0" then + ip = luci.sys.exec("uci -q get network.lan.ipaddr |awk -F '/' '{print $1}' 2>/dev/null |tr -d '\n'") + else + ip = luci.sys.exec(string.format("ip address show %s | grep -w 'inet' 2>/dev/null |grep -Eo 'inet [0-9\.]+' | awk '{print $2}' | tr -d '\n'", lan_int_name)) + end if not ip or ip == "" then ip = luci.sys.exec("ip address show $(uci -q -p /tmp/state get network.lan.ifname) | grep -w 'inet' 2>/dev/null |grep -Eo 'inet [0-9\.]+' | awk '{print $2}' | tr -d '\n'") end diff --git a/luci-app-openclash/root/usr/share/openclash/openclash_debug_getcon.lua b/luci-app-openclash/root/usr/share/openclash/openclash_debug_getcon.lua index ca546f5f9c..db6377f64e 100644 --- a/luci-app-openclash/root/usr/share/openclash/openclash_debug_getcon.lua +++ b/luci-app-openclash/root/usr/share/openclash/openclash_debug_getcon.lua @@ -20,8 +20,13 @@ return string.format("%.1f",e)..a[t] end local function debug_getcon() - local info, ip, host, diag_info - ip = luci.sys.exec("uci -q get network.lan.ipaddr |awk -F '/' '{print $1}' 2>/dev/null |tr -d '\n'") + local info, ip, host, diag_info, lan_int_name + lan_int_name = uci:get("openclash", "config", "lan_interface_name") or "0" + if lan_int_name == "0" then + ip = luci.sys.exec("uci -q get network.lan.ipaddr |awk -F '/' '{print $1}' 2>/dev/null |tr -d '\n'") + else + ip = luci.sys.exec(string.format("ip address show %s | grep -w 'inet' 2>/dev/null |grep -Eo 'inet [0-9\.]+' | awk '{print $2}' | tr -d '\n'", lan_int_name)) + end if not ip or ip == "" then ip = luci.sys.exec("ip address show $(uci -q -p /tmp/state get network.lan.ifname) | grep -w 'inet' 2>/dev/null |grep -Eo 'inet [0-9\.]+' | awk '{print $2}' | tr -d '\n'") end diff --git a/luci-app-openclash/root/usr/share/openclash/openclash_history_get.sh b/luci-app-openclash/root/usr/share/openclash/openclash_history_get.sh index 714ba9a62e..44efafded0 100644 --- a/luci-app-openclash/root/usr/share/openclash/openclash_history_get.sh +++ b/luci-app-openclash/root/usr/share/openclash/openclash_history_get.sh @@ -14,7 +14,12 @@ del_lock() { close_all_conection() { SECRET=$(uci -q get openclash.config.dashboard_password) - LAN_IP=$(uci -q get network.lan.ipaddr |awk -F '/' '{print $1}' 2>/dev/null || ip addr show 2>/dev/null | grep -w 'inet' | grep 'global' | grep 'brd' | grep -Eo 'inet [0-9\.]+' | awk '{print $2}' | head -n 1) + lan_interface_name=$(uci -q get openclash.config.lan_interface_name || echo "0") + if [ "$lan_interface_name" = "0" ]; then + LAN_IP=$(uci -q get network.lan.ipaddr |awk -F '/' '{print $1}' 2>/dev/null || ip address show $(uci -q -p /tmp/state get network.lan.ifname || uci -q -p /tmp/state get network.lan.device) | grep -w "inet" 2>/dev/null |grep -Eo 'inet [0-9\.]+' | awk '{print $2}' || ip addr show 2>/dev/null | grep -w 'inet' | grep 'global' | grep 'brd' | grep -Eo 'inet [0-9\.]+' | awk '{print $2}' | head -n 1) + else + LAN_IP=$(ip address show $(uci -q -p $lan_interface_name) | grep -w "inet" 2>/dev/null |grep -Eo 'inet [0-9\.]+' | awk '{print $2}') + fi PORT=$(uci -q get openclash.config.cn_port) curl -m 2 -H "Authorization: Bearer ${SECRET}" -H "Content-Type:application/json" -X DELETE http://"$LAN_IP":"$PORT"/connections >/dev/null 2>&1 } From 759306e2a9d1e1b5606338a242aca4b4061051b4 Mon Sep 17 00:00:00 2001 From: vernesong <42875168+vernesong@users.noreply.github.com> Date: Sat, 18 May 2024 19:41:07 +0800 Subject: [PATCH 36/36] 0.46.011 --- luci-app-openclash/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/luci-app-openclash/Makefile b/luci-app-openclash/Makefile index 8d4d01d366..e755bec70f 100644 --- a/luci-app-openclash/Makefile +++ b/luci-app-openclash/Makefile @@ -1,7 +1,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-openclash -PKG_VERSION:=0.46.010 +PKG_VERSION:=0.46.011 PKG_RELEASE:=beta PKG_MAINTAINER:=vernesong