webshare/quick-start.sh

105 lines
3.0 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
echo "=== Webshare 代理快速启动脚本 ==="
echo ""
# 检查参数
if [ $# -eq 0 ]; then
echo "使用方法:"
echo " $0 <甲骨文Tailscale IP> # 启动代理转发"
echo " $0 test # 测试现有连接"
echo " $0 stop # 停止所有代理"
echo ""
echo "示例:"
echo " $0 100.64.0.1"
exit 1
fi
case "$1" in
"test")
echo "测试代理连接..."
if command -v python3 &> /dev/null; then
python3 -c "
import requests
import concurrent.futures
def test_proxy(port):
try:
proxy = f'socks5://127.0.0.1:{port}'
r = requests.get('http://httpbin.org/ip',
proxies={'http': proxy, 'https': proxy},
timeout=5)
return port, r.json().get('origin', 'Unknown')
except:
return port, None
ports = range(20001, 20006) # 测试前5个
with concurrent.futures.ThreadPoolExecutor(max_workers=5) as executor:
results = list(executor.map(test_proxy, ports))
for port, ip in results:
if ip:
print(f'✓ 端口 {port}: {ip}')
else:
print(f'✗ 端口 {port}: 连接失败')
"
else
echo "需要 Python3 来测试代理"
echo "手动测试:"
echo "curl --socks5 127.0.0.1:20001 http://httpbin.org/ip"
fi
;;
"stop")
echo "停止所有代理转发..."
pkill -f "gost.*:2000" 2>/dev/null
pkill -f "proxy-manager.py" 2>/dev/null
echo "已停止"
;;
*)
ORACLE_IP="$1"
echo "甲骨文服务器 IP: $ORACLE_IP"
# 检查 gost
if ! command -v gost &> /dev/null; then
echo "错误: 未找到 gost请先运行 local-client-setup.sh"
exit 1
fi
# 检查 Python 管理器
if [ -f "proxy-manager.py" ] && command -v python3 &> /dev/null; then
echo "使用 Python 管理器启动..."
python3 proxy-manager.py "$ORACLE_IP"
else
echo "使用 shell 脚本启动..."
# 停止旧的进程
pkill -f "gost.*:2000" 2>/dev/null
# 启动转发
echo "启动代理转发..."
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 -n "."
sleep 0.1
done
echo ""
echo "代理转发已启动!"
echo "本地 SOCKS5 代理: 127.0.0.1:20001-20020"
echo ""
echo "测试连接: $0 test"
echo "停止服务: $0 stop"
echo ""
echo "按 Ctrl+C 停止..."
# 等待
trap 'echo "正在停止..."; pkill -f "gost.*:2000"; exit' INT
wait
fi
;;
esac