diff --git a/mihomo/Makefile b/mihomo/Makefile new file mode 100644 index 0000000..752e2e3 --- /dev/null +++ b/mihomo/Makefile @@ -0,0 +1,78 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# Copyright (C) 2025 Entware + +include $(TOPDIR)/rules.mk + +PKG_NAME:=mihomo +PKG_VERSION:=1.19.19 +PKG_RELEASE:=1 + +PKG_SOURCE_PROTO:=git +PKG_SOURCE_VERSION:=v$(PKG_VERSION) +PKG_SOURCE_URL:=https://github.com/MetaCubeX/mihomo +PKG_MIRROR_HASH:=92614443f400c5cb4e83e0e9cd03c890eb4957f23366a657a8f05f0c0a64d9fc + +PKG_LICENSE:=MIT +PKG_LICENSE_FILES:=LICENSE + +PKG_BUILD_PARALLEL:=1 + +include $(INCLUDE_DIR)/package.mk +include $(INCLUDE_DIR)/golang.mk + +define Package/mihomo/Default + SECTION:=net + CATEGORY:=Network + SUBMENU:=Web Servers/Proxies + TITLE:=Mihomo (MetaCubeX) universal proxy + URL:=https://github.com/MetaCubeX/mihomo + MAINTAINER:=Entware team, https://entware.net + DEPENDS:=+ca-certificates +endef + +define Package/mihomo + $(call Package/mihomo/Default) + VARIANT:=hf +endef + +define Package/mihomo_nohf + $(call Package/mihomo/Default) + VARIANT:=nohf + DEPENDS:=+ca-certificates @arm +endef + +define Package/mihomo/description +Mihomo is a rule-based proxy platform written in Go. +endef + +Package/mihomo_nohf/description=$(Package/mihomo/description) + +define Package/mihomo/conffiles +/opt/etc/mihomo/config.yaml +endef + +Package/mihomo_nohf/conffiles=$(Package/mihomo/conffiles) + +XIMPORTPATH:=$(call tolower,$(XIMPORTPATH)) + +GO_LDFLAGS += \ + -X '$(XIMPORTPATH)/constant.Version=$(PKG_VERSION)' \ + -X '$(XIMPORTPATH)/constant.BuildTime=' + +GO_TARGET:=./ +GO_TAGS:=with_gvisor + +define Package/mihomo/install + $(INSTALL_DIR) $(1)/opt/sbin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/bin/mihomo $(1)/opt/sbin/mihomo + $(INSTALL_DIR) $(1)/opt/etc/init.d + $(INSTALL_BIN) ./files/S99mihomo $(1)/opt/etc/init.d + $(INSTALL_DIR) $(1)/opt/etc/mihomo + $(INSTALL_CONF) ./files/config.yaml $(1)/opt/etc/mihomo +endef + +Package/mihomo_nohf/install=$(Package/mihomo/install) + +$(eval $(call BuildPackage,mihomo)) +$(eval $(call BuildPackage,mihomo_nohf)) diff --git a/mihomo/files/S99mihomo b/mihomo/files/S99mihomo new file mode 100644 index 0000000..f74da23 --- /dev/null +++ b/mihomo/files/S99mihomo @@ -0,0 +1,10 @@ +#!/bin/sh + +ENABLED=yes +PROCS=mihomo +ARGS="-d /opt/etc/mihomo" +PREARGS="" +DESC=$PROCS +PATH=/opt/sbin:/opt/bin:/opt/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin + +. /opt/etc/init.d/rc.func diff --git a/mihomo/files/config.yaml b/mihomo/files/config.yaml new file mode 100644 index 0000000..f3c8229 --- /dev/null +++ b/mihomo/files/config.yaml @@ -0,0 +1,4 @@ +tproxy-port: 1181 +redir-port: 1182 +# Setup documentation: +# https://wiki.metacubex.one/en/config/