update 2025-01-03 20:24:43

This commit is contained in:
actions-user 2025-01-03 20:24:43 +08:00
parent 137ebf7a0f
commit 4d834676ab
10 changed files with 41 additions and 95 deletions

View File

@ -1,6 +1,6 @@
include $(TOPDIR)/rules.mk
PKG_VERSION:=1.17.0
PKG_VERSION:=1.17.1
LUCI_TITLE:=LuCI Support for mihomo
LUCI_DEPENDS:=+luci-base +mihomo

View File

@ -4,7 +4,6 @@ bin = require "nixio".bin
fs = require "nixio.fs"
sys = require "luci.sys"
uci = require "luci.model.uci".cursor()
libuci = require "uci".cursor()
util = require "luci.util"
datatypes = require "luci.cbi.datatypes"
jsonc = require "luci.jsonc"
@ -35,33 +34,20 @@ function is_js_luci()
return sys.call('[ -f "/www/luci-static/resources/uci.js" ]') == 0
end
function uci_set_list(cursor, config, section, option, value)
if config and section and option then
if not value or #value == 0 then
return cursor:delete(config, section, option)
end
return cursor:set(
config, section, option,
( type(value) == "table" and value or { value } )
)
end
return false
end
function uci_section(cursor, config, type, name, values)
local stat = true
if name then
stat = cursor:set(config, name, type)
else
name = cursor:add(config, type)
stat = name and true
end
return stat and name
function is_old_uci()
return sys.call("grep 'require \"uci\"' /usr/lib/lua/luci/model/uci.lua >/dev/null 2>&1") == 0
end
function uci_save(cursor, config, commit, apply)
if is_js_luci() then
if is_old_uci() then
cursor:save(config)
if commit then
cursor:commit(config)
if apply then
sys.call("/etc/init.d/" .. config .. " reload > /dev/null 2>&1 &")
end
end
else
commit = true
if commit then
if apply then
@ -70,14 +56,6 @@ function uci_save(cursor, config, commit, apply)
sh_uci_commit(config)
end
end
else
cursor:save(config)
if commit then
cursor:commit(config)
if apply then
sys.call("/etc/init.d/" .. config .. " reload > /dev/null 2>&1 &")
end
end
end
end

View File

@ -233,11 +233,7 @@ check_ver() {
get_new_port() {
port=$1
[ "$port" == "auto" ] && {
port=2082
local GET_NEW_PORT=$(get_cache_var "get_new_port")
[ -n "${GET_NEW_PORT}" ] && port=${GET_NEW_PORT}
}
[ "$port" == "auto" ] && port=2082
protocol=$(echo $2 | tr 'A-Z' 'a-z')
result=$(check_port_exists $port $protocol)
if [ "$result" != 0 ]; then
@ -249,7 +245,6 @@ get_new_port() {
fi
get_new_port $temp $protocol
else
set_cache_var "get_new_port" "$port"
echo $port
fi
}

View File

@ -17,7 +17,7 @@ local ssub, slen, schar, sbyte, sformat, sgsub = string.sub, string.len, string.
local split = api.split
local jsonParse, jsonStringify = luci.jsonc.parse, luci.jsonc.stringify
local base64Decode = api.base64Decode
local uci = api.libuci
local uci = api.uci
local fs = api.fs
uci:revert(appname)
@ -228,7 +228,7 @@ do
set = function(o)
for kk, vv in pairs(CONFIG) do
if (vv.remarks == id .. "备用节点的列表") then
api.uci_set_list(uci, appname, id, "autoswitch_backup_node", vv.new_nodes)
uci:set_list(appname, id, "autoswitch_backup_node", vv.new_nodes)
end
end
end
@ -299,8 +299,8 @@ do
if (vv.remarks == "Xray负载均衡节点[" .. node_id .. "]列表") then
uci:foreach(appname, "nodes", function(node2)
if node2[".name"] == node[".name"] then
local section = api.uci_section(uci, appname, "nodes", node_id)
api.uci_set_list(uci, appname, section, "balancing_node", vv.new_nodes)
local section = uci:section(appname, "nodes", node_id)
uci:set_list(appname, section, "balancing_node", vv.new_nodes)
end
end)
end
@ -1454,7 +1454,7 @@ local function update_node(manual)
local remark = v["remark"]
local list = v["list"]
for _, vv in ipairs(list) do
local cfgid = api.uci_section(uci, appname, "nodes", api.gen_short_uuid())
local cfgid = uci:section(appname, "nodes", api.gen_short_uuid())
for kkk, vvv in pairs(vv) do
uci:set(appname, cfgid, kkk, vvv)
-- sing-box 域名解析策略

View File

@ -72,7 +72,7 @@ url_test_node() {
/usr/share/${CONFIG}/app.sh run_socks flag="url_test_${node_id}" node=${node_id} bind=127.0.0.1 socks_port=${_tmp_port} config_file=url_test_${node_id}.json
local curlx="socks5h://127.0.0.1:${_tmp_port}"
fi
# sleep 1s
sleep 1s
# 兼容 curl 8.6 time_starttransfer 错误
local curl_ver=$(curl -V 2>/dev/null | head -n 1 | awk '{print $2}' | cut -d. -f1,2)
local curl_arg="-w %{http_code}:%{time_starttransfer} http://"

View File

@ -3,7 +3,6 @@ local com = require "luci.passwall2.com"
bin = require "nixio".bin
fs = require "nixio.fs"
sys = require "luci.sys"
libuci = require "uci".cursor()
uci = require"luci.model.uci".cursor()
util = require "luci.util"
datatypes = require "luci.cbi.datatypes"
@ -30,33 +29,20 @@ function log(...)
end
end
function uci_set_list(cursor, config, section, option, value)
if config and section and option then
if not value or #value == 0 then
return cursor:delete(config, section, option)
end
return cursor:set(
config, section, option,
( type(value) == "table" and value or { value } )
)
end
return false
end
function uci_section(cursor, config, type, name, values)
local stat = true
if name then
stat = cursor:set(config, name, type)
else
name = cursor:add(config, type)
stat = name and true
end
return stat and name
function is_old_uci()
return sys.call("grep 'require \"uci\"' /usr/lib/lua/luci/model/uci.lua >/dev/null 2>&1") == 0
end
function uci_save(cursor, config, commit, apply)
if is_js_luci() then
if is_old_uci() then
cursor:save(config)
if commit then
cursor:commit(config)
if apply then
sys.call("/etc/init.d/" .. config .. " reload > /dev/null 2>&1 &")
end
end
else
commit = true
if commit then
if apply then
@ -65,14 +51,6 @@ function uci_save(cursor, config, commit, apply)
sh_uci_commit(config)
end
end
else
cursor:save(config)
if commit then
cursor:commit(config)
if apply then
sys.call("/etc/init.d/" .. config .. " reload > /dev/null 2>&1 &")
end
end
end
end

View File

@ -209,11 +209,7 @@ check_depends() {
get_new_port() {
port=$1
[ "$port" == "auto" ] && {
port=2082
local GET_NEW_PORT=$(get_cache_var "get_new_port")
[ -n "${GET_NEW_PORT}" ] && port=${GET_NEW_PORT}
}
[ "$port" == "auto" ] && port=2082
protocol=$(echo $2 | tr 'A-Z' 'a-z')
result=$(check_port_exists $port $protocol)
if [ "$result" != 0 ]; then
@ -225,7 +221,6 @@ get_new_port() {
fi
get_new_port $temp $protocol
else
set_cache_var "get_new_port" "$port"
echo $port
fi
}

View File

@ -17,7 +17,7 @@ local ssub, slen, schar, sbyte, sformat, sgsub = string.sub, string.len, string.
local split = api.split
local jsonParse, jsonStringify = luci.jsonc.parse, luci.jsonc.stringify
local base64Decode = api.base64Decode
local uci = api.libuci
local uci = api.uci
local fs = api.fs
uci:revert(appname)
@ -212,7 +212,7 @@ do
set = function(o)
for kk, vv in pairs(CONFIG) do
if (vv.remarks == id .. "备用节点的列表") then
api.uci_set_list(uci, appname, id, "autoswitch_backup_node", vv.new_nodes)
uci:set_list(appname, id, "autoswitch_backup_node", vv.new_nodes)
end
end
end
@ -284,8 +284,8 @@ do
if (vv.remarks == "Xray负载均衡节点[" .. node_id .. "]列表") then
uci:foreach(appname, "nodes", function(node2)
if node2[".name"] == node[".name"] then
local section = api.uci_section(uci, appname, "nodes", node_id)
api.uci_set_list(uci, appname, section, "balancing_node", vv.new_nodes)
local section = uci:section(appname, "nodes", node_id)
uci:set_list(appname, section, "balancing_node", vv.new_nodes)
end
end)
end
@ -1423,7 +1423,7 @@ local function update_node(manual)
local remark = v["remark"]
local list = v["list"]
for _, vv in ipairs(list) do
local cfgid = api.uci_section(uci, appname, "nodes", api.gen_short_uuid())
local cfgid = uci:section(appname, "nodes", api.gen_short_uuid())
for kkk, vvv in pairs(vv) do
uci:set(appname, cfgid, kkk, vvv)
-- sing-box 域名解析策略

View File

@ -1,7 +1,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=mihomo
PKG_RELEASE:=2
PKG_RELEASE:=3
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://github.com/MetaCubeX/mihomo.git

View File

@ -183,7 +183,7 @@ table inet mihomo {
ip6 daddr @china_ip6 counter return
meta nfproto ipv4 meta l4proto . th dport != @proxy_dport ip daddr != $FAKE_IP counter return
meta nfproto ipv6 meta l4proto . th dport != @proxy_dport counter return
meta l4proto { tcp, udp } ip dscp == @bypass_dscp counter return
meta l4proto { tcp, udp } ip dscp == @bypass_dscp ip daddr != $FAKE_IP counter return
meta l4proto { tcp, udp } ip6 dscp == @bypass_dscp counter return
}
@ -199,7 +199,7 @@ table inet mihomo {
ip6 daddr @china_ip6 counter return
meta nfproto ipv4 meta l4proto . th dport != @proxy_dport ip daddr != $FAKE_IP counter return
meta nfproto ipv6 meta l4proto . th dport != @proxy_dport counter return
meta l4proto { tcp, udp } ip dscp == @bypass_dscp counter return
meta l4proto { tcp, udp } ip dscp == @bypass_dscp ip daddr != $FAKE_IP counter return
meta l4proto { tcp, udp } ip6 dscp == @bypass_dscp counter return
}
@ -215,7 +215,7 @@ table inet mihomo {
ip6 daddr @china_ip6 counter return
meta nfproto ipv4 meta l4proto . th dport != @proxy_dport ip daddr != $FAKE_IP counter return
meta nfproto ipv6 meta l4proto . th dport != @proxy_dport counter return
meta l4proto { tcp, udp } ip dscp == @bypass_dscp counter return
meta l4proto { tcp, udp } ip dscp == @bypass_dscp ip daddr != $FAKE_IP counter return
meta l4proto { tcp, udp } ip6 dscp == @bypass_dscp counter return
meta l4proto udp th dport 53 counter return
}
@ -232,7 +232,7 @@ table inet mihomo {
ip6 daddr @china_ip6 counter return
meta nfproto ipv4 meta l4proto . th dport != @proxy_dport ip daddr != $FAKE_IP counter return
meta nfproto ipv6 meta l4proto . th dport != @proxy_dport counter return
meta l4proto { tcp, udp } ip dscp == @bypass_dscp counter return
meta l4proto { tcp, udp } ip dscp == @bypass_dscp ip daddr != $FAKE_IP counter return
meta l4proto { tcp, udp } ip6 dscp == @bypass_dscp counter return
meta l4proto udp th dport 53 counter return
}