fix: refresh stale cellular source IP and resolve cpxy symlink BASE
WWAN re-dial often keeps iface name (wwan0) but changes private IP. Stale inet4_bind_address then makes SOCKS rep=0x01 while the panel still looks healthy. generate/cpxy now re-read live source IP on each regenerate. Also fix /usr/local/bin/cpxy symlink: dirname($0) became /usr/local and broke rebind/generate (missing lib.sh).
This commit is contained in:
+16
-3
@@ -13,9 +13,22 @@ cell="$(resolve_cellular 2>/dev/null || true)"
|
||||
if [[ -z "$cell" ]]; then
|
||||
resolve_cellular >/dev/null || true
|
||||
fi
|
||||
src_ip="${CELLULAR_SOURCE_IP:-}"
|
||||
if [[ -z "$src_ip" && -n "$cell" ]]; then
|
||||
src_ip="$(detect_source_ip "$cell" || true)"
|
||||
|
||||
# 始终以当前网卡实 IP 为准:WWAN 重拨后 iface 名常不变,但 CELLULAR_SOURCE_IP 会过期。
|
||||
# 过期的 inet4_bind_address 会导致 sing-box 出站失败 → 客户端 SOCKS rep=0x01。
|
||||
live_src=""
|
||||
if [[ -n "$cell" ]]; then
|
||||
live_src="$(detect_source_ip "$cell" || true)"
|
||||
fi
|
||||
src_ip="${live_src:-${CELLULAR_SOURCE_IP:-}}"
|
||||
if [[ -n "$cell" && -n "$live_src" && "${CELLULAR_SOURCE_IP:-}" != "$live_src" ]]; then
|
||||
info "源 IP 已漂移: ${CELLULAR_SOURCE_IP:-<空>} → $live_src,写回 settings"
|
||||
persist_cellular_to_settings "${CONFIG_FILE:-$ROOT_DIR/etc/settings.conf}" "$cell" "$live_src" || true
|
||||
# 兼容 live 安装布局:settings 在 etc/
|
||||
if [[ -f /opt/cellular-proxy/etc/settings.conf ]]; then
|
||||
persist_cellular_to_settings /opt/cellular-proxy/etc/settings.conf "$cell" "$live_src" || true
|
||||
fi
|
||||
CELLULAR_SOURCE_IP="$live_src"
|
||||
fi
|
||||
|
||||
if [[ -z "$cell" ]]; then
|
||||
|
||||
Reference in New Issue
Block a user