#!/bin/bash set -e # 参数 SERVER_IP="$1" SNI="$2" CLIENT_PLATFORM="$3" # 示例用法提示 if [[ -z "$SERVER_IP" || -z "$SNI" || -z "$CLIENT_PLATFORM" ]]; then echo "用法: $0 --ip <服务器IP> --sni <伪装域名> --client-platform " exit 1 fi UUID=$(uuidgen) KEYPAIR=$(sing-box generate reality-keypair) PRIVATE_KEY=$(echo "$KEYPAIR" | grep PrivateKey | awk '{print $2}') PUBLIC_KEY=$(echo "$KEYPAIR" | grep PublicKey | awk '{print $2}') SHORT_ID=$(head /dev/urandom | tr -dc a-z0-9 | head -c 4) # 安装 sing-box(以 Debian 为例) if ! command -v sing-box &>/dev/null; then echo "🔧 安装 sing-box..." curl -fsSL https://sing-box.app/install | bash fi # 创建配置目录 mkdir -p /etc/sing-box # 写入服务端配置 cat > /etc/sing-box/config-server.json < /etc/systemd/system/sing-box.service <