Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

increase timeout and 3 retries for testing ipv6 connectivity #24

Merged
merged 1 commit into from
May 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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