From d7d7c332828e6e2b8591ad78f77b3454a4e4df06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milien=20=28perso=29?= <4016501+unixfox@users.noreply.github.com> Date: Thu, 23 May 2024 00:00:11 +0200 Subject: [PATCH] increase timeout and 3 retries for testing ipv6 connectivity (#24) --- smart_ipv6_rotator/helpers.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/smart_ipv6_rotator/helpers.py b/smart_ipv6_rotator/helpers.py index 4e19fa1..7e1794e 100644 --- a/smart_ipv6_rotator/helpers.py +++ b/smart_ipv6_rotator/helpers.py @@ -2,10 +2,12 @@ import os import sys from dataclasses import asdict +from requests.adapters import HTTPAdapter from time import sleep from typing import Iterator import requests +from requests.adapters import HTTPAdapter from smart_ipv6_rotator.const import ICANHAZIP_IPV6_ADDRESS, IPROUTE, JSON_CONFIG_FILE from smart_ipv6_rotator.models import SavedRanges @@ -19,7 +21,9 @@ def root_check(skip_root: bool = False) -> None: def check_ipv6_connectivity() -> None: try: - requests.get("http://ipv6.icanhazip.com", timeout=5) + s = requests.Session() + s.mount('http://', HTTPAdapter(max_retries=3)) + s.get("http://ipv6.icanhazip.com", timeout=10) except requests.Timeout: sys.exit("[Error] You do not have IPv6 connectivity. This script can not work.") except requests.HTTPError: