From d08ff19470afb3be5cf5e0f1d2ea701f9b7d5d5f Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 6 Apr 2026 14:48:21 +0000 Subject: [PATCH] Improve LAN detection: check Headscale port response, not just ping Ping 192.168.0.100 can false-positive if external pharmacy has a device at that IP. Now checks if 192.168.0.100:8070 actually responds like Headscale. Co-Authored-By: Claude Opus 4.6 (1M context) --- pharmq-setup.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pharmq-setup.sh b/pharmq-setup.sh index 132fb5f..5af07e6 100644 --- a/pharmq-setup.sh +++ b/pharmq-setup.sh @@ -171,11 +171,14 @@ phase2_tailscale_pve() { print_phase "Phase 2/8: PVE Host Tailscale 등록" # Headscale 서버 주소 자동 감지 (LAN vs 외부) + # ping만으로는 부정확 (외부 약국에 192.168.0.100 장비가 있을 수 있음) + # → Headscale 8070 포트에 실제 응답하는지 확인 if [ -z "$HEADSCALE_SERVER" ]; then print_step "Headscale 서버 접근 경로 감지 중..." - if ping -c1 -W2 192.168.0.100 >/dev/null 2>&1; then + if curl -s --connect-timeout 3 http://192.168.0.100:8070/health 2>/dev/null | grep -qi "ok\|healthy" || \ + curl -s --connect-timeout 3 -o /dev/null -w "%{http_code}" http://192.168.0.100:8070/ 2>/dev/null | grep -q "200\|404"; then HEADSCALE_SERVER="$HEADSCALE_SERVER_LAN" - print_ok "LAN 감지 → 직접 연결 ($HEADSCALE_SERVER)" + print_ok "LAN Headscale 감지 → 직접 연결 ($HEADSCALE_SERVER)" else HEADSCALE_SERVER="$HEADSCALE_SERVER_EXT" print_ok "외부 네트워크 → 도메인 경유 ($HEADSCALE_SERVER)"