This commit is contained in:
2026-07-23 15:59:00 +08:00
parent 9ab7ba66f3
commit 3bf04be347
19 changed files with 1144 additions and 34 deletions

View File

@@ -1,5 +1,5 @@
#!/bin/bash
# OpenVPN 连通后拉起 SOCKS5dante/sockd仅服务戎行内网代理
# OpenVPN 连通后拉起 microsocks出口跟随系统路由含 tun0避免 Dante 绑错网卡
set -euo pipefail
VPN_DIR="${VPN_DIR:-/vpn}"
@@ -48,15 +48,25 @@ for i in $(seq 1 90); do
sleep 1
done
# 生成 dante 配置并后台启动 sockd
sed "s/__SOCKS_PORT__/${SOCKS_PORT}/g" /etc/sockd.conf.template > /etc/sockd.conf
sockd -f /etc/sockd.conf -D
SOCKS_PID="$(pidof sockd | awk '{print $1}')"
if [ -z "${SOCKS_PID}" ]; then
echo "[rongxing-vpn] sockd 启动失败"
echo "[rongxing-vpn] 路由表:"
ip route || true
# 直连自检(不阻断)
if curl -sS -m 5 -o /tmp/rx_probe.out -w "[rongxing-vpn] 直连探测 HTTP %{http_code}\n" "http://${RONGXING_HOST}:7007/" ; then
head -c 200 /tmp/rx_probe.out 2>/dev/null || true
echo
else
echo "[rongxing-vpn] 直连探测失败: http://${RONGXING_HOST}:7007/"
fi
microsocks -i "$SOCKS_HOST" -p "$SOCKS_PORT" &
SOCKS_PID=$!
sleep 1
if ! kill -0 "$SOCKS_PID" 2>/dev/null; then
echo "[rongxing-vpn] microsocks 启动失败"
exit 1
fi
echo "[rongxing-vpn] SOCKS5 已监听 :${SOCKS_PORT} (pid=${SOCKS_PID})"
echo "[rongxing-vpn] SOCKS5 已监听 :${SOCKS_PORT} (microsocks pid=${SOCKS_PID})"
cleanup() {
kill "$SOCKS_PID" 2>/dev/null || true