refine: tunnel verify - tighter retries, stderr-first on 000, announce DoH fallback
Reviewer feedback: cut worst-case stall from ~200s to ~60s (urllib 2x, DoH 4x with max-time 10); when curl reports 000 (connect failure) prefer stderr for the diagnostic; print an explicit note when falling back to DoH after a resolved-DNS urllib failure.
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -302,7 +302,8 @@ def cells() -> list[dict]:
|
|||||||
" ext_ok = False\n"
|
" ext_ok = False\n"
|
||||||
" _last_err = None\n"
|
" _last_err = None\n"
|
||||||
" if _dns_ip:\n"
|
" if _dns_ip:\n"
|
||||||
" for _ in range(6):\n"
|
" # DNS가 풀리면 터널도 이미 연결된 상태 — 2회면 충분\n"
|
||||||
|
" for _ in range(2):\n"
|
||||||
" try:\n"
|
" try:\n"
|
||||||
" ext = urllib.request.urlopen(TUNNEL_URL + '/health', timeout=15)\n"
|
" ext = urllib.request.urlopen(TUNNEL_URL + '/health', timeout=15)\n"
|
||||||
" print(' 외부 접속 검증 OK (HTTP', ext.status, ')')\n"
|
" print(' 외부 접속 검증 OK (HTTP', ext.status, ')')\n"
|
||||||
@@ -312,18 +313,25 @@ def cells() -> list[dict]:
|
|||||||
" _last_err = _e\n"
|
" _last_err = _e\n"
|
||||||
" time.sleep(2)\n"
|
" time.sleep(2)\n"
|
||||||
" if not ext_ok and shutil.which('curl'):\n"
|
" if not ext_ok and shutil.which('curl'):\n"
|
||||||
|
" if _dns_ip:\n"
|
||||||
|
" print(' (시스템 DNS 경로 실패 — DoH로 우회 검증 시도)')\n"
|
||||||
" # VM DNS 우회: Cloudflare DoH로 호스트 해석 → 터널 직접 접속 (외부와 동일 경로)\n"
|
" # VM DNS 우회: Cloudflare DoH로 호스트 해석 → 터널 직접 접속 (외부와 동일 경로)\n"
|
||||||
" for _ in range(6):\n"
|
" for _ in range(4):\n"
|
||||||
" _c = subprocess.run(\n"
|
" _c = subprocess.run(\n"
|
||||||
" ['curl', '-sS', '-o', '/dev/null', '-w', '%{http_code}', '--max-time', '15',\n"
|
" ['curl', '-sS', '-o', '/dev/null', '-w', '%{http_code}', '--max-time', '10',\n"
|
||||||
" '--doh-url', 'https://cloudflare-dns.com/dns-query', TUNNEL_URL + '/health'],\n"
|
" '--doh-url', 'https://cloudflare-dns.com/dns-query', TUNNEL_URL + '/health'],\n"
|
||||||
" capture_output=True, text=True,\n"
|
" capture_output=True, text=True,\n"
|
||||||
" )\n"
|
" )\n"
|
||||||
" if _c.stdout.strip() == '200':\n"
|
" _code = _c.stdout.strip()\n"
|
||||||
|
" if _code == '200':\n"
|
||||||
" print(' 외부 접속 검증 OK (DoH 우회, HTTP 200)')\n"
|
" print(' 외부 접속 검증 OK (DoH 우회, HTTP 200)')\n"
|
||||||
" ext_ok = True\n"
|
" ext_ok = True\n"
|
||||||
" break\n"
|
" break\n"
|
||||||
" _last_err = _c.stdout.strip() or _c.stderr.strip() or _last_err\n"
|
" # '000'은 접속 실패 — stderr가 더 설명적\n"
|
||||||
|
" if _code == '000':\n"
|
||||||
|
" _last_err = _c.stderr.strip() or _last_err\n"
|
||||||
|
" else:\n"
|
||||||
|
" _last_err = _code or _c.stderr.strip() or _last_err\n"
|
||||||
" time.sleep(2)\n"
|
" time.sleep(2)\n"
|
||||||
" if not ext_ok:\n"
|
" if not ext_ok:\n"
|
||||||
" print(' 자동 검증 불가 — 브라우저에서 직접 열어보세요:', TUNNEL_URL + '/docs')\n"
|
" print(' 자동 검증 불가 — 브라우저에서 직접 열어보세요:', TUNNEL_URL + '/docs')\n"
|
||||||
|
|||||||
Reference in New Issue
Block a user