Skip to content

Commit

Permalink
increase timeout and 3 retries for testing ipv6 connectivity (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
unixfox authored May 22, 2024
1 parent f9484f0 commit d7d7c33
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion smart_ipv6_rotator/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down

0 comments on commit d7d7c33

Please sign in to comment.