Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
vernesong committed May 18, 2024
2 parents 8ebe09e + 759306e commit d0141ee
Show file tree
Hide file tree
Showing 29 changed files with 866 additions and 252 deletions.
47 changes: 46 additions & 1 deletion .github/workflows/compile_meta_core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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 .
Expand Down
5 changes: 1 addition & 4 deletions luci-app-openclash/Makefile
Original file line number Diff line number Diff line change
@@ -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 <https://github.com/vernesong/OpenClash>

Expand Down Expand Up @@ -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
Expand Down
31 changes: 20 additions & 11 deletions luci-app-openclash/luasrc/controller/openclash.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down
2 changes: 2 additions & 0 deletions luci-app-openclash/luasrc/model/cbi/openclash/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 14 additions & 3 deletions luci-app-openclash/luasrc/model/cbi/openclash/config-overwrite.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,19 @@ bold_off = [[</strong>]]

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:").." <a href='javascript:void(0)' onclick='javascript:restore_config(this)'>http://"..lan_ip.."/cgi-bin/luci/admin/services/openclash/restore</a>"
Expand Down Expand Up @@ -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:").." ".."<a href='javascript:void(0)' onclick='javascript:return winOpen(\"https://ghproxy.com/\")'>https://ghproxy.com/</a>"
o.description = translate("Modify The Github Address In The Config And OpenClash With Proxy(CDN) To Prevent File Download Faild. Format Reference:").." ".."<a href='javascript:void(0)' onclick='javascript:return winOpen(\"https://mirror.ghproxy.com/\")'>https://mirror.ghproxy.com/</a>"
o:value("0", translate("Disable"))
o:value("https://fastly.jsdelivr.net/")
o:value("https://testingcf.jsdelivr.net/")
Expand Down
58 changes: 43 additions & 15 deletions luci-app-openclash/luasrc/model/cbi/openclash/servers-config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ local hysteria_protocols = {
"faketcp"
}

local hysteria2_protocols = {
"udp"
}

local obfs = {
"plain",
"http_simple",
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -682,32 +704,38 @@ 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"))
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
Expand Down
34 changes: 31 additions & 3 deletions luci-app-openclash/luasrc/model/cbi/openclash/settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,19 @@ bold_off = [[</strong>]]

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:").." <a href='javascript:void(0)' onclick='javascript:restore_config(this)'>http://"..lan_ip.."/cgi-bin/luci/admin/services/openclash/restore</a>"..
Expand Down Expand Up @@ -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")
Expand All @@ -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")
Expand Down Expand Up @@ -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

Expand Down
Loading

0 comments on commit d0141ee

Please sign in to comment.