From 449b60b38f69f9aa95d8c973552491e46a4a3f3c Mon Sep 17 00:00:00 2001 From: Nik Afiq Date: Tue, 12 May 2026 23:16:40 +0900 Subject: [PATCH] fix: improve IP retrieval logic with retry mechanism and timeout --- manifests/media/qbittorrent.yaml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/manifests/media/qbittorrent.yaml b/manifests/media/qbittorrent.yaml index ffd078a..31e1fb1 100644 --- a/manifests/media/qbittorrent.yaml +++ b/manifests/media/qbittorrent.yaml @@ -95,14 +95,17 @@ spec: - python3 - -c - | - import http.server, urllib.request + import http.server, urllib.request, time class Handler(http.server.BaseHTTPRequestHandler): def do_GET(self): - try: - ip = urllib.request.urlopen('https://ipinfo.io/ip').read().decode().strip() - except Exception as e: - ip = f'error: {e}' + ip = 'connecting...' + for _ in range(5): + try: + ip = urllib.request.urlopen('https://ipinfo.io/ip', timeout=5).read().decode().strip() + break + except Exception: + time.sleep(2) body = f'''