diff --git a/.github/workflows/compile_meta_core.yml b/.github/workflows/compile_meta_core.yml index 580fcbd02f..96814cb643 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 -p tmp/loong64_abi1/bin + cp ./OpenClash/.github/makefile/meta_loongarch_abi1 ./tmp/loong64_abi1/Makefile + + - name: Copy loongarch abi2 Makefile + run: | + cd .. + mkdir -p 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,37 @@ 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 + + - 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 +152,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 . diff --git a/luci-app-openclash/Makefile b/luci-app-openclash/Makefile index f8333d64b5..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.003 +PKG_VERSION:=0.46.011 PKG_RELEASE:=beta PKG_MAINTAINER:=vernesong @@ -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/luasrc/controller/openclash.lua b/luci-app-openclash/luasrc/controller/openclash.lua index 2d993e38ff..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 @@ -345,21 +351,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 +414,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..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" @@ -69,7 +80,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/servers-config.lua b/luci-app-openclash/luasrc/model/cbi/openclash/servers-config.lua index 47e930fb89..1b88b24078 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(Value, "ports", translate("Port Hopping")) +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 Range")) 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,18 +289,29 @@ 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.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 = 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") @@ -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 (Unit:second)")) +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/luasrc/model/cbi/openclash/settings.lua b/luci-app-openclash/luasrc/model/cbi/openclash/settings.lua index 659d57be04..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".. @@ -256,7 +267,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") @@ -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") @@ -1297,6 +1324,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/myip.htm b/luci-app-openclash/luasrc/view/openclash/myip.htm index 7a4ebb1193..ac044e5c39 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,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: () => { @@ -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/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..4f4cca596d 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 d532a126fc..623051b835 100644 --- a/luci-app-openclash/luasrc/view/openclash/update.htm +++ b/luci-app-openclash/luasrc/view/openclash/update.htm @@ -15,6 +15,10 @@ + + + + @@ -80,6 +84,11 @@ <%:Collecting data...%>

+ +

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

+

<%:Collecting data...%> @@ -149,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 = ''; @@ -173,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 = ''; @@ -539,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 44a68bd864..7feecee524 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 "日志等级" @@ -726,7 +726,7 @@ msgstr "协议" msgid "Protocol param(optional)" msgstr "传输协议参数(可选)" -msgid "Obfs" +msgid "obfs" msgstr "混淆插件" msgid "Obfs param(optional)" @@ -765,6 +765,36 @@ msgstr "策略组配置(使用一键生成配置文件功能时无需设置) msgid "Proxies" 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 "启用传输协议设置" + +msgid "Hysterir QUIC parameters" +msgstr "QUIC 参数" + msgid "Edit Rule Providers" msgstr "编辑规则集配置" @@ -1389,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 "最新版本获取失败,请稍后再试!" @@ -1425,12 +1458,6 @@ msgstr "页面已切换为 Redir-Host 模式!" msgid "IP Address" msgstr "IP 地址" -msgid "Mainland" -msgstr "国内" - -msgid "Abroad" -msgstr "国外" - msgid "Website Access Check" msgstr "网站访问检查" @@ -1641,11 +1668,11 @@ 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 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 "版本内核没有更新,停止继续操作!" @@ -3496,4 +3523,31 @@ msgid "Skip Proxy Address" msgstr "绕过服务器地址" msgid "Bypassing Server Addresses And Preventing Duplicate Proxies" -msgstr "绕过服务器地址,防止重复代理" \ No newline at end of file +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 "请参考示例输入正确的链接地址!" + +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/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' diff --git a/luci-app-openclash/root/etc/init.d/openclash b/luci-app-openclash/root/etc/init.d/openclash index b54031ed1f..45a30435f9 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 @@ -934,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 @@ -1525,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' @@ -1841,6 +1873,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 @@ -2129,9 +2164,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 @@ -2158,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' @@ -2278,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 @@ -2617,7 +2674,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 @@ -2889,9 +2949,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_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 fi #bypass gateway compatible @@ -2921,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 @@ -3061,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) @@ -3101,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/etc/uci-defaults/luci-openclash b/luci-app-openclash/root/etc/uci-defaults/luci-openclash index 98bf0d7b5c..57db341641 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 @@ -196,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 set firewall."$section".network="$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 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.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 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..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 @@ -115,13 +125,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 +142,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 +151,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,23 +170,23 @@ 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!" 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 @@ -188,7 +201,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 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 b567fb6450..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 @@ -22,61 +27,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_v6 then + info_v6 = json.parse(info_v6) 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)) + 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 +96,4 @@ local function debug_dns() os.exit(0) end -debug_dns() \ No newline at end of file +debug_dns() 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 } 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 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| 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 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..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 @@ -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 @@ -1035,7 +1036,21 @@ do system(hysteria_protocol) end }.join + end; + 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 + end; + + if '$server_type' == 'hysteria' or '$server_type' == 'hysteria2' then + #hysteria hysteria2 Thread.new{ #hysteria_up if Value['proxies'][$count].key?('up') then @@ -1044,6 +1059,7 @@ do end }.join + #hysteria hysteria2 Thread.new{ #hysteria_down if Value['proxies'][$count].key?('down') then @@ -1052,6 +1068,7 @@ do end }.join + #hysteria hysteria2 Thread.new{ #skip-cert-verify if Value['proxies'][$count].key?('skip-cert-verify') then @@ -1060,6 +1077,7 @@ do end }.join + #hysteria hysteria2 Thread.new{ #sni if Value['proxies'][$count].key?('sni') then @@ -1068,6 +1086,7 @@ do end }.join + #hysteria hysteria2 Thread.new{ #alpn if Value['proxies'][$count].key?('alpn') then @@ -1085,6 +1104,7 @@ do end; }.join + #hysteria Thread.new{ #recv_window_conn if Value['proxies'][$count].key?('recv-window-conn') then @@ -1093,6 +1113,7 @@ do end }.join + #hysteria Thread.new{ #recv_window if Value['proxies'][$count].key?('recv-window') then @@ -1101,6 +1122,7 @@ do end }.join + #hysteria hysteria2 Thread.new{ #hysteria_obfs if Value['proxies'][$count].key?('obfs') then @@ -1109,6 +1131,7 @@ do end }.join + #hysteria hysteria2 Thread.new{ #hysteria_obfs_password if Value['proxies'][$count].key?('obfs-password') then @@ -1117,6 +1140,7 @@ do end }.join + #hysteria Thread.new{ #hysteria_auth if Value['proxies'][$count].key?('auth') then @@ -1125,6 +1149,7 @@ do end }.join + #hysteria Thread.new{ #hysteria_auth_str if Value['proxies'][$count].key?('auth-str') then @@ -1133,6 +1158,7 @@ do end }.join + #hysteria hysteria2 Thread.new{ #hysteria_ca if Value['proxies'][$count].key?('ca') then @@ -1141,6 +1167,7 @@ do end }.join + #hysteria hysteria2 Thread.new{ #hysteria_ca_str if Value['proxies'][$count].key?('ca-str') then @@ -1149,6 +1176,7 @@ do end }.join + #hysteria Thread.new{ #disable_mtu_discovery if Value['proxies'][$count].key?('disable-mtu-discovery') then @@ -1157,6 +1185,7 @@ do end }.join + #hysteria Thread.new{ #fast_open if Value['proxies'][$count].key?('fast-open') then @@ -1165,6 +1194,7 @@ do end }.join + #hysteria hysteria2 Thread.new{ #fingerprint if Value['proxies'][$count].key?('fingerprint') then @@ -1173,6 +1203,7 @@ do end }.join + #hysteria hysteria2 Thread.new{ #ports if Value['proxies'][$count].key?('ports') then @@ -1181,6 +1212,7 @@ do end }.join + #hysteria hysteria2 Thread.new{ #hop-interval if Value['proxies'][$count].key?('hop-interval') then @@ -1573,4 +1605,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 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" +}