increase timeout and 3 retries for testing ipv6 connectivity (#24)

This commit is contained in:
Émilien (perso) 2024-05-23 00:00:11 +02:00 committed by GitHub
parent f9484f0412
commit d7d7c33282
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2,10 +2,12 @@ import json
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: