diff --git a/k8s/apps/pasarguard/configmap-scripts-ingress.yaml b/k8s/apps/pasarguard/configmap-scripts-ingress.yaml index 3ab93c3..730a0f0 100644 --- a/k8s/apps/pasarguard/configmap-scripts-ingress.yaml +++ b/k8s/apps/pasarguard/configmap-scripts-ingress.yaml @@ -254,7 +254,8 @@ data: # Detect xray API port BEFORE starting monitoring loop echo "Detecting xray API port..." for i in $(seq 1 60); do - API_PORT=$(netstat -tlpn 2>/dev/null | grep xray | grep 127.0.0.1 | awk '{print $4}' | cut -d: -f2 | head -1) + # Without hostNetwork, use ss to check listening ports in the same network namespace + API_PORT=$(ss -tlnp 2>/dev/null | grep xray | grep 127.0.0.1 | awk '{print $4}' | sed 's/.*://' | head -1) if [ -n "$API_PORT" ]; then echo "Found xray API port: $API_PORT" echo -n "$API_PORT" > /shared/xray-api-port @@ -273,7 +274,7 @@ data: LAST_PORT="$API_PORT" while true; do - API_PORT=$(netstat -tlpn 2>/dev/null | grep xray | grep 127.0.0.1 | awk '{print $4}' | cut -d: -f2 | head -1) + API_PORT=$(ss -tlnp 2>/dev/null | grep xray | grep 127.0.0.1 | awk '{print $4}' | sed 's/.*://' | head -1) if [ -n "$API_PORT" ] && [ "$API_PORT" != "$LAST_PORT" ]; then echo "API port changed from $LAST_PORT to $API_PORT" echo -n "$API_PORT" > /shared/xray-api-port