添加proxy快捷函数,添加controller提示信息

This commit is contained in:
Steven Hobs
2025-08-23 00:13:15 +08:00
parent f5de874864
commit ea68743d89
2 changed files with 103 additions and 89 deletions

12
activate Normal file
View File

@@ -0,0 +1,12 @@
echo "=> Mihomo proxy functions activated"
function setproxy() {
local host=${1:-127.0.0.1} # 更改IP为您的代理软件监听IP, 默认127.0.0.1
local port=${2:-7890} # 更改端口为您的代理软件监听端口, 默认7890
export http_proxy=http://$host:$port && export https_proxy=$http_proxy
export no_proxy=localhost,127.0.0.1,::1,.localdomain
echo "- You've set the network proxy! Info: $http_proxy"
}
function unsetproxy() {
unset http_proxy && unset https_proxy && unset no_proxy
echo "- You've unset the network proxy!"
}

14
run.sh
View File

@@ -5,6 +5,8 @@ MIHOMO_URL="https://github.com/MetaCubeX/mihomo/releases/download/v1.19.12/mihom
MIHOMO_UI_URL="https://github.com/MetaCubeX/metacubexd/releases/download/v1.190.1/compressed-dist.tgz"
echo "mihomo-run (version:1.0)"
echo "ui controller: http://localhost:19090/ui"
echo "ui secret: $MIHOMO_CTL_AUTH"
MH_DIR=$(dirname "$(readlink -f "$0")")
# 检查函数检查核心文件、UI文件和进程状态
@@ -46,7 +48,7 @@ mihomo_check_environment() {
# Args解析
case "$1" in
"")
"")
# 执行环境检查
mihomo_check_environment
@@ -59,7 +61,7 @@ case "$1" in
echo "=> Starting mihomo with default config..."
"$MH_DIR/bin/mihomo" -d "$MH_DIR/data" -f "$CONFIG_FILE" -ext-ui "$MH_DIR/ui" -ext-ctl 0.0.0.0:19090 -secret "$MIHOMO_CTL_AUTH"
;;
"use")
"use")
# 执行环境检查
mihomo_check_environment
@@ -76,17 +78,17 @@ case "$1" in
echo "=> Starting mihomo with profile: $2"
"$MH_DIR/bin/mihomo" -d "$MH_DIR/data" -f "$CONFIG_FILE" -ext-ui "$MH_DIR/ui" -ext-ctl 0.0.0.0:19090 -secret "$MIHOMO_CTL_AUTH"
;;
"list")
"list")
# list则为展示所有的profiles
echo "=> Available profiles:"
ls "$MH_DIR/profiles"/*.yaml | sed 's/.*profiles\/\(.*\)\.yaml/\1/'
;;
"stop")
"stop")
# stop则是终止mihomo进程
echo "=> Stopping mihomo..."
pkill -f "$MH_DIR/bin/mihomo"
;;
"help")
"help")
# help 打印帮助信息
echo "Usage: $0 [command] [options]"
echo ""
@@ -103,7 +105,7 @@ case "$1" in
echo " $0 list Show all profiles"
echo " $0 stop Stop mihomo"
;;
*)
*)
echo "Invalid argument: $1"
echo "Use '$0 help' to see available commands"
exit 1