From d4f3d96837cfe5eece20fe780eb7983bbb988440 Mon Sep 17 00:00:00 2001 From: mango Date: Fri, 17 Apr 2026 00:25:30 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20Debian=20sniproxy=20=E4=BB=8E=E6=BA=90?= =?UTF-8?q?=E7=A0=81=E7=BC=96=E8=AF=91=E5=AE=89=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/stream-unlock.sh | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/scripts/stream-unlock.sh b/scripts/stream-unlock.sh index 7be3868..6090be1 100644 --- a/scripts/stream-unlock.sh +++ b/scripts/stream-unlock.sh @@ -128,7 +128,38 @@ install_sniproxy() { # 安装依赖 if [[ "$OS" == "debian" ]]; then apt update - apt install -y sniproxy dnsmasq ufw + # 先尝试直接安装 + if ! apt install -y sniproxy 2>/dev/null; then + echo -e "${YELLOW}sniproxy 不在默认仓库,从源码编译...${NC}" + # 安装编译依赖 + apt install -y build-essential libev-dev libudns-dev pkg-config git + # 克隆并编译 + cd /tmp + git clone https://github.com/dlundquist/sniproxy.git + cd sniproxy + ./configure --prefix=/usr + make -j$(nproc) + make install + # 创建 systemd 服务 + cat > /etc/systemd/system/sniproxy.service << 'SERVICE' +[Unit] +Description=sniproxy +After=network.target + +[Service] +Type=forking +ExecStart=/usr/sbin/sniproxy -c /etc/sniproxy.conf +PIDFile=/var/run/sniproxy.pid +Restart=on-failure + +[Install] +WantedBy=multi-user.target +SERVICE + systemctl daemon-reload + cd / + rm -rf /tmp/sniproxy + fi + apt install -y dnsmasq ufw elif [[ "$OS" == "centos" ]]; then yum install -y epel-release yum install -y sniproxy dnsmasq firewalld