mosdns/start.sh

73 lines
1.9 KiB
Bash
Executable File

#!/bin/bash
# ========================================
# MosDNS 快速启动脚本
# ========================================
set -e
# 颜色定义
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
CYAN='\033[0;36m'
NC='\033[0m'
echo ""
echo -e "${CYAN}========================================${NC}"
echo -e "${CYAN} MosDNS 智能防污染 DNS 服务器${NC}"
echo -e "${CYAN}========================================${NC}"
echo ""
# 检查可执行文件
if [ ! -f "dist/mosdns-linux-amd64" ]; then
echo -e "${YELLOW}⚠️ 未找到可执行文件,开始构建...${NC}"
if [ -f "build-all-platforms.sh" ]; then
chmod +x build-all-platforms.sh
echo "1" | ./build-all-platforms.sh
else
echo -e "${RED}❌ 构建脚本不存在${NC}"
exit 1
fi
fi
# 检查配置文件
if [ ! -f "config.yaml" ]; then
echo -e "${RED}❌ 配置文件 config.yaml 不存在${NC}"
echo -e "${YELLOW}💡 请先创建配置文件或复制示例配置${NC}"
exit 1
fi
# 检查 CN IP 数据文件
if [ ! -f "data/chn_ip.txt" ]; then
echo -e "${YELLOW}⚠️ 警告: data/chn_ip.txt 不存在${NC}"
echo -e "${YELLOW} 智能防污染功能需要此文件${NC}"
# 创建最小数据文件
mkdir -p data
echo "# CN IP 地址表(示例)" > data/chn_ip.txt
echo "1.0.0.0/8" >> data/chn_ip.txt
echo ""
fi
echo -e "${GREEN}✅ 准备就绪${NC}"
echo ""
echo -e "${CYAN}启动参数:${NC}"
echo " 可执行文件: dist/mosdns-linux-amd64"
echo " 配置文件: config.yaml"
echo ""
echo -e "${CYAN}服务地址:${NC}"
echo " DNS 服务: 0.0.0.0:53 (UDP/TCP)"
echo " Web 界面: http://localhost:5555"
echo " API 接口: http://localhost:8080"
echo ""
echo -e "${CYAN}========================================${NC}"
echo ""
# 启动 MosDNS
echo -e "${GREEN}🚀 正在启动 MosDNS...${NC}"
echo ""
./dist/mosdns-linux-amd64 start -c config.yaml