#!/bin/bash echo "=== 本地客户端设置 ===" # 配置你的甲骨文 Tailscale IP ORACLE_IP="100.x.x.x" # 请替换为实际的甲骨文 Tailscale IP echo "请先设置甲骨文服务器的 Tailscale IP:" read -p "输入甲骨文服务器的 Tailscale IP: " ORACLE_IP if [ -z "$ORACLE_IP" ]; then echo "IP 地址不能为空" exit 1 fi # 1. 安装 gost(如果没有) echo "检查 gost..." if ! command -v gost &> /dev/null; then echo "安装 gost..." wget -O gost.gz https://github.com/ginuerzh/gost/releases/download/v2.11.5/gost-linux-amd64-2.11.5.gz gunzip gost.gz chmod +x gost-linux-amd64-2.11.5 sudo mv gost-linux-amd64-2.11.5 /usr/local/bin/gost echo "gost 安装完成" fi # 2. 创建本地转发脚本 cat > start-local-forward.sh << EOF #!/bin/bash echo "启动本地代理转发..." echo "甲骨文服务器: $ORACLE_IP" # 杀死之前的进程 pkill -f "gost.*:2000" # 启动20个本地转发 for i in {1..20}; do local_port=\$((20000 + i)) oracle_port=\$((10000 + i)) # 本地端口 -> 甲骨文端口 gost -L "socks5://127.0.0.1:\$local_port" -F "socks5://$ORACLE_IP:\$oracle_port" & echo "本地端口 \$local_port -> 甲骨文 $ORACLE_IP:\$oracle_port" sleep 0.1 done echo "" echo "本地代理转发已启动!" echo "SOCKS5 代理地址: 127.0.0.1:20001-20020" echo "" echo "测试命令:" echo "curl --socks5 127.0.0.1:20001 http://httpbin.org/ip" echo "" echo "按 Ctrl+C 停止" wait EOF chmod +x start-local-forward.sh # 3. 创建测试脚本 cat > test-proxies.sh << 'EOF' #!/bin/bash echo "测试代理连接..." for i in {1..5}; do # 只测试前5个 port=$((20000 + i)) echo -n "测试端口 $port: " result=$(timeout 10 curl -s --socks5 127.0.0.1:$port http://httpbin.org/ip 2>/dev/null | jq -r '.origin' 2>/dev/null) if [ -n "$result" ]; then echo "✓ $result" else echo "✗ 连接失败" fi done EOF chmod +x test-proxies.sh # 4. 创建 Clash 配置 cat > clash-webshare-config.yaml << 'EOF' port: 7890 socks-port: 7891 allow-lan: true mode: Rule log-level: info external-controller: 127.0.0.1:9090 proxies: EOF for i in {1..20}; do port=$((20000 + i)) cat >> clash-webshare-config.yaml << EOF - name: "WebShare-$i" type: socks5 server: 127.0.0.1 port: $port EOF done cat >> clash-webshare-config.yaml << 'EOF' proxy-groups: - name: "WebShare" type: select proxies: EOF for i in {1..20}; do echo " - \"WebShare-$i\"" >> clash-webshare-config.yaml done cat >> clash-webshare-config.yaml << 'EOF' - name: "LoadBalance" type: load-balance url: http://www.gstatic.com/generate_204 interval: 300 proxies: EOF for i in {1..20}; do echo " - \"WebShare-$i\"" >> clash-webshare-config.yaml done cat >> clash-webshare-config.yaml << 'EOF' rules: - MATCH,WebShare EOF echo "" echo "=== 设置完成 ===" echo "" echo "使用步骤:" echo "1. 确保甲骨文服务器已启动代理中转" echo "2. 运行: ./start-local-forward.sh" echo "3. 测试: ./test-proxies.sh" echo "4. 使用 Clash: clash -f clash-webshare-config.yaml" echo "" echo "本地 SOCKS5 代理: 127.0.0.1:20001-20020"