🗽 Sync 2026-10-26 14:45:36

This commit is contained in:
github-actions[bot] committed 2026-10-26 14:45:36 +08:00
1 parent d9474ffda8
commit ac10e08480
60 files changed
+4186 -1605

No files matched your search

+49 -11
View File
@@ -1,19 +1,20 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=clashoo
PKG_SHORT_SHA:=6780eee
PKG_COMMIT_DATE:=2026.10.25
PKG_UPSTREAM_VERSION:=1.19.33
PKG_UPSTREAM_TAG:=v$(PKG_UPSTREAM_VERSION)
PKG_SHORT_SHA:=3f27ef3
PKG_VERSION:=$(PKG_COMMIT_DATE)~$(PKG_SHORT_SHA)
PKG_RELEASE:=18
PKG_VERSION:=2026.10.25.$(PKG_UPSTREAM_VERSION)
PKG_RELEASE:=19
PKG_SOURCE:=$(PKG_NAME)-alpha-$(PKG_SHORT_SHA).tar.gz
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-alpha-$(PKG_SHORT_SHA)
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-alpha-$(PKG_SHORT_SHA)
PKG_SOURCE:=$(PKG_NAME)-stable-$(PKG_UPSTREAM_TAG)-$(PKG_SHORT_SHA).tar.gz
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-stable-$(PKG_UPSTREAM_TAG)-$(PKG_SHORT_SHA)
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_SOURCE_SUBDIR)
PKG_SOURCE_URL:=https://github.com/kenzok8/openwrt-clashoo/releases/download/mihomo-src
PKG_SOURCE_VERSION:=d831028ec8a3d336ea83295bea36c32fdc973ede
PKG_SOURCE_VERSION:=57468807be288af4250181a024e29c2971eb228c
PKG_HASH:=skip
PKG_BUILD_VERSION:=alpha-$(PKG_SHORT_SHA)
PKG_BUILD_VERSION:=$(PKG_UPSTREAM_TAG)
PKG_LICENSE:=GPL3.0+
PKG_MAINTAINER:=kenzok8
@@ -50,8 +51,11 @@ endef
define Package/clashoo/install
$(call GoPackage/Package/Install/Bin,$(1))
$(INSTALL_DIR) $(1)/usr/libexec/clashoo
$(INSTALL_DIR) $(1)/usr/bin
ln -sf /usr/bin/mihomo $(1)/usr/bin/clash-meta
mv -f $(1)/usr/bin/mihomo $(1)/usr/libexec/clashoo/mihomo-stable
ln -sf /usr/libexec/clashoo/mihomo-stable $(1)/usr/bin/mihomo
ln -sf /usr/libexec/clashoo/mihomo-stable $(1)/usr/bin/clash-meta
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_DIR) $(1)/etc/config
@@ -82,10 +86,44 @@ define Package/clashoo/install
$(RM) $(1)/usr/share/clashoo/core_down_complete
endef
define Package/clashoo/preinst
#!/bin/sh
if [ -z "$${IPKG_INSTROOT}" ]; then
save_core() {
src="$$1"
dst="$$2"
[ -f "$$src" ] && [ ! -L "$$src" ] || return 0
if [ -e "$$dst" ] || [ -L "$$dst" ]; then return 0; fi
mkdir -p "$$(dirname "$$dst")" || return 1
tmp="$$dst.tmp.$$$$"
cp "$$src" "$$tmp" && chmod 0755 "$$tmp" && cmp -s "$$src" "$$tmp" || {
rm -f "$$tmp"
return 1
}
if command -v sha256sum >/dev/null 2>&1; then
old_hash="$$(sha256sum "$$src" | awk '{print $$1}')"
new_hash="$$(sha256sum "$$tmp" | awk '{print $$1}')"
[ "$$old_hash" = "$$new_hash" ] || {
rm -f "$$tmp"
return 1
}
fi
mv -f "$$tmp" "$$dst"
}
save_core /usr/bin/mihomo /usr/share/clashoo/bin/mihomo-alpha || exit 1
save_core /usr/bin/mihomo-stable /usr/share/clashoo/bin/mihomo-stable || exit 1
if [ -x /usr/bin/clash-meta ] && [ ! -L /usr/bin/clash-meta ] && [ ! -e /usr/share/clashoo/bin/mihomo-stable ]; then
if ! /usr/bin/clash-meta -v 2>/dev/null | grep -Eiq '(alpha|beta|rc|pre|smart)'; then
save_core /usr/bin/clash-meta /usr/share/clashoo/bin/mihomo-stable || exit 1
fi
fi
fi
exit 0
endef
define Package/clashoo/postinst
#!/bin/sh
if [ -z "$${IPKG_INSTROOT}" ]; then
[ -x /usr/bin/mihomo ] && [ ! -x /usr/bin/clash-meta ] && ln -sf /usr/bin/mihomo /usr/bin/clash-meta
rm -f /usr/share/clashoo/check_luci_version.sh /usr/share/clashoo/check_clash_meta_version.sh /usr/share/clashoo/check_mihomo_core_version.sh
rm -f /usr/share/clashoo/cuslist.sh /usr/share/clashoo/groups.sh /usr/share/clashoo/load_groups.sh /usr/share/clashoo/panel_diag.sh
rm -f /usr/share/clashoo/rmlist.sh /usr/share/clashoo/uplist.sh /usr/share/clashoo/rpc_restart_async.sh /usr/share/clashoo/rpc_update_china_ip_async.sh
+2 -2
View File
@@ -9,7 +9,7 @@ config clashoo 'config'
option dash_port '9090'
option dashboard_panel 'zashboard'
option level 'info'
option core '3'
option core '2'
option allow_lan '1'
option dnsforwader '1'
option subcri 'meta'
@@ -28,7 +28,7 @@ config clashoo 'config'
option listen_port '1053'
option interf '0'
option download_core 'amd64-compatible'
option dcore '3'
option dcore '2'
option same_tag '1'
option geoip_source '3'
option geoip_format 'mmdb'
+47 -37
View File
@@ -169,43 +169,54 @@ cleanup_stale_core_nft() {
}
_core_candidates() {
echo "/usr/bin/mihomo-stable /usr/bin/mihomo /usr/bin/clash-meta /etc/clashoo/clash"
echo "/usr/share/clashoo/bin/mihomo-stable /usr/libexec/clashoo/mihomo-stable /usr/share/clashoo/bin/mihomo-alpha /usr/bin/mihomo /usr/bin/clash-meta /etc/clashoo/clash"
}
_migrate_legacy_mihomo_stable() {
local legacy=/usr/bin/clash-meta version
[ -x /usr/bin/mihomo-stable ] && return 0
local legacy=/usr/bin/clash-meta target=/usr/share/clashoo/bin/mihomo-stable version staged
[ -x "$target" ] && return 0
[ -x "$legacy" ] && [ ! -L "$legacy" ] || return 0
version=$("$legacy" -v 2>/dev/null | head -n 1)
[ -n "$version" ] || return 0
echo "$version" | grep -Eiq '(alpha|beta|rc|pre|smart)' && return 0
cp -f "$legacy" /usr/bin/mihomo-stable 2>/dev/null && chmod 0755 /usr/bin/mihomo-stable
mkdir -p "$(dirname "$target")" || return 1
staged="${target}.$$"
cp -f "$legacy" "$staged" 2>/dev/null && chmod 0755 "$staged" && mv -f "$staged" "$target"
}
_fallback_missing_mihomo_core() {
local selected fallback
is_singbox_selected && return 0
selected="$(uci -q get clashoo.config.core 2>/dev/null)"
case "$selected" in
2)
[ -x /usr/bin/mihomo-stable ] && return 0
[ -x /usr/bin/mihomo ] || return 0
fallback=3
;;
3)
[ -x /usr/bin/mihomo ] && return 0
[ -x /usr/bin/mihomo-stable ] || return 0
fallback=2
;;
*) return 0 ;;
esac
uci -q set clashoo.config.core="$fallback"
uci -q set clashoo.config.dcore="$fallback"
uci -q commit clashoo >/dev/null 2>&1
if [ "$fallback" = "3" ]; then
log_msg "Stable core missing, falling back to Alpha" "稳定版内核缺失,自动回退到 Alpha"
_mihomo_stable_binary() {
local bundled=/usr/libexec/clashoo/mihomo-stable manual=/usr/share/clashoo/bin/mihomo-stable bundled_ver manual_ver
# A successful custom download is an explicit override, even if its version is older.
if [ -x "$manual" ] &&
[ "$(sed -n '1{s/^[[:space:]]*//;s/[[:space:]]*$//;p;}' /usr/share/clashoo/clash_meta_version 2>/dev/null)" = "custom-url" ]; then
echo "$manual"
return 0
fi
[ -x "$bundled" ] || { [ -x "$manual" ] && { echo "$manual"; return 0; }; return 1; }
[ -x "$manual" ] || { echo "$bundled"; return; }
bundled_ver="$("$bundled" -v 2>/dev/null | awk '{for (i = 1; i < NF; i++) if ($i == "Meta") {print $(i + 1); exit}}')"
manual_ver="$("$manual" -v 2>/dev/null | awk '{for (i = 1; i < NF; i++) if ($i == "Meta") {print $(i + 1); exit}}')"
bundled_ver="${bundled_ver#v}"
manual_ver="${manual_ver#v}"
printf '%s\n' "$bundled_ver" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+$' || bundled_ver=""
printf '%s\n' "$manual_ver" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+$' || manual_ver=""
if [ -n "$bundled_ver" ] && [ -n "$manual_ver" ]; then
if awk -v manual="$manual_ver" -v bundled="$bundled_ver" 'BEGIN {
split(manual, m, "."); split(bundled, b, ".");
for (i = 1; i <= 3; i++) {
if (m[i] + 0 > b[i] + 0) exit 0;
if (m[i] + 0 < b[i] + 0) exit 1;
}
exit 0;
}'; then
echo "$manual"
else
echo "$bundled"
fi
elif [ -n "$manual_ver" ]; then
echo "$manual"
else
log_msg "Alpha core missing, falling back to stable" "Alpha 内核缺失,自动回退到稳定版"
echo "$bundled"
fi
}
@@ -220,11 +231,11 @@ _detect_selected_core() {
return 1
;;
2|mihomo)
[ -x /usr/bin/mihomo-stable ] && echo /usr/bin/mihomo-stable && return
return 1
_mihomo_stable_binary
return $?
;;
3|mihomo-alpha)
[ -x /usr/bin/mihomo ] && echo /usr/bin/mihomo && return
[ -x /usr/share/clashoo/bin/mihomo-alpha ] && echo /usr/share/clashoo/bin/mihomo-alpha && return
return 1
;;
esac
@@ -233,7 +244,7 @@ _detect_selected_core() {
core_supports_advanced_features() {
case "$CLASH" in
*/mihomo|*/mihomo-stable|*/clash-meta|*/smart)
*/mihomo|*/mihomo-stable|*/mihomo-alpha|*/clash-meta|*/smart)
return 0
;;
*)
@@ -2126,12 +2137,12 @@ _start_validate_core() {
echo "Clashoo" > "$REAL_LOG"
return 1
elif [ "${core:-0}" -eq 2 ] && [ ! -x "$CLASH" ]; then
log_msg "mihomo core not found, detected binary is unavailable: $CLASH" "找不到可用的 mihomo 内核: $CLASH"
log_msg "mihomo stable core not found, detected binary is unavailable: $CLASH" "找不到可用的 mihomo 稳定版内核: $CLASH"
sleep 1
echo "Clashoo" > "$REAL_LOG"
return 1
elif [ "${core:-0}" -eq 3 ] && [ ! -x "$CLASH" ]; then
log_msg "mihomo core not found, detected binary is unavailable: $CLASH" "找不到可用的 mihomo 内核: $CLASH"
log_msg "mihomo Alpha core not found, detected binary is unavailable: $CLASH" "找不到可用的 mihomo Alpha 内核,请在组件更新中安装: $CLASH"
sleep 1
echo "Clashoo" > "$REAL_LOG"
return 1
@@ -2167,10 +2178,10 @@ _start_prepare_config() {
if { egrep -q '^ {0,}rule-providers:' "$CONFIG_YAML" || egrep -q '^ {0,}script:' "$CONFIG_YAML"; } && ! core_supports_advanced_features; then
[ "$_reload_candidate" = "1" ] && return 1
if [ -x /usr/bin/mihomo ]; then
uci set clashoo.config.core="3" && uci commit clashoo
elif [ -x /usr/bin/mihomo-stable ]; then
if [ -n "$(_mihomo_stable_binary)" ]; then
uci set clashoo.config.core="2" && uci commit clashoo
elif [ -x /usr/share/clashoo/bin/mihomo-alpha ]; then
uci set clashoo.config.core="3" && uci commit clashoo
else
log_msg "Current config requires mihomo/clash-meta core" "当前配置需要 mihomo 或 clash-meta 内核"
backend_remove_rules >/dev/null 2>&1
@@ -2407,7 +2418,6 @@ start_service(){
sync_legacy_core_field
_migrate_legacy_mihomo_stable
_fallback_missing_mihomo_core
CLASH="$(_detect_selected_core)"
cleanup_legacy_startup_backups
@@ -1062,10 +1062,10 @@ if [ -n "$CUSTOM_CORE_URL" ]; then
write_log "使用自定义内核下载链接"
URL="$CUSTOM_CORE_URL"
if [ "$CORETYPE" = "3" ]; then
TARGET="/usr/bin/mihomo"
TARGET="/usr/share/clashoo/bin/mihomo-alpha"
VERSION_FILE="/usr/share/clashoo/mihomo_version"
else
TARGET="/usr/bin/mihomo-stable"
TARGET="/usr/share/clashoo/bin/mihomo-stable"
VERSION_FILE="/usr/share/clashoo/clash_meta_version"
fi
TAG="custom"
@@ -1175,7 +1175,7 @@ elif [ "$CORETYPE" = "2" ]; then
[ -z "$TAG" ] && write_log "获取稳定版版本号失败" && exit 1
ASSET=$(pick_mihomo_asset "MetaCubeX/mihomo" "$TAG" "$(map_mihomo_arch "$MODELTYPE")" "stable")
URL="https://github.com/MetaCubeX/mihomo/releases/download/${TAG}/${ASSET}"
TARGET="/usr/bin/mihomo-stable"
TARGET="/usr/share/clashoo/bin/mihomo-stable"
VERSION_FILE="/usr/share/clashoo/clash_meta_version"
VERSION_VALUE="$TAG"
else
@@ -1189,7 +1189,7 @@ else
[ -z "$ASSET" ] && ASSET=$(pick_mihomo_asset "MetaCubeX/mihomo" "$TAG" "$(map_mihomo_arch "$MODELTYPE")" "alpha")
[ -z "$ASSET" ] && ASSET=$(pick_mihomo_asset "MetaCubeX/mihomo" "$TAG" "$(map_mihomo_arch "$MODELTYPE")" "stable")
URL="https://github.com/MetaCubeX/mihomo/releases/download/${TAG}/${ASSET}"
TARGET="/usr/bin/mihomo"
TARGET="/usr/share/clashoo/bin/mihomo-alpha"
VERSION_FILE="/usr/share/clashoo/mihomo_version"
VERSION_VALUE="$(printf '%s\n' "$ASSET" | sed -n 's#^mihomo-.*-alpha-\([0-9a-fA-F]\{7,\}\)\.gz$#\1#p' | head -n 1)"
[ -z "$VERSION_VALUE" ] && VERSION_VALUE="$TAG"