Allow disabling checker

This commit is contained in:
monosans
2024-09-18 18:30:59 +03:00
parent aa57dbfafc
commit 88ca6413c5
3 changed files with 26 additions and 16 deletions
+2
View File
@@ -18,6 +18,8 @@ max_connections = 512
# Example:
# check_website = "https://google.com"
# check_website = "https://httpbin.smp.io/ip"
# Disable checking:
# check_website = ""
check_website = "https://checkip.amazonaws.com"
# Set to false to sort proxies alphabetically.
+9 -7
View File
@@ -153,15 +153,17 @@ async def main() -> None:
await session.close()
count_before_checking = storage.get_count()
should_save = True
await checker.check_all(
settings=settings,
storage=storage,
progress=progress,
proxies_count=count_before_checking,
)
if settings.check_website:
await checker.check_all(
settings=settings,
storage=storage,
progress=progress,
proxies_count=count_before_checking,
)
finally:
if should_save:
storage.remove_unchecked()
if settings.check_website:
storage.remove_unchecked()
count_after_checking = storage.get_count()
console.print(
get_summary_table(
+15 -9
View File
@@ -143,6 +143,8 @@ async def _get_check_website_type_and_real_ip(
Literal[CheckWebsiteType.PLAIN_IP, CheckWebsiteType.HTTPBIN_IP], str
]
):
if not check_website:
return CheckWebsiteType.UNKNOWN, None
try:
async with session.get(check_website) as response:
content = await response.read()
@@ -252,16 +254,20 @@ class Settings:
value: str,
/,
) -> None:
parsed_url = urlparse(value)
if parsed_url.scheme not in {"http", "https"} or not parsed_url.netloc:
msg = f"invalid check_website: {value}"
raise ValueError(msg)
if value:
parsed_url = urlparse(value)
if (
parsed_url.scheme not in {"http", "https"}
or not parsed_url.netloc
):
msg = f"invalid check_website: {value}"
raise ValueError(msg)
if parsed_url.scheme == "http":
logger.warning(
"check_website uses the http protocol. "
"It is recommended to use https for correct checking."
)
if parsed_url.scheme == "http":
logger.warning(
"check_website uses the http protocol. "
"It is recommended to use https for correct checking."
)
@timeout.validator
def _validate_timeout(