Skip to content

Commit

Permalink
Update ECODFF to 2.0.33
Browse files Browse the repository at this point in the history
* If we check main domain, then we should also try www version if not www fails
* Display also few exception messages
  • Loading branch information
hawkeye116477 committed Sep 20, 2024
1 parent 838c8e5 commit 7dcd352
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions scripts/ECODFF.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
import git

# Version number
SCRIPT_VERSION = "2.0.32"
SCRIPT_VERSION = "2.0.33"

# Parse arguments
parser = argparse.ArgumentParser()
Expand Down Expand Up @@ -144,10 +144,12 @@ async def domain_dns_check(domain, limit):
try:
print(f"Checking the status of {domain}...")
answers_NS = await custom_resolver.resolve(domain, "NS")
except (NXDOMAIN, Timeout):
except (NXDOMAIN, Timeout) as ex:
print(f"{ex} ({domain})")
status = "offline"
except (NoAnswer, NoNameservers):
except (NoAnswer, NoNameservers) as ex:
try:
print(f"{ex} ({domain})")
print(f"Checking the status of {domain} again...")
await custom_resolver.resolve(domain)
except (NXDOMAIN, Timeout, NoAnswer, NoNameservers):
Expand Down Expand Up @@ -306,11 +308,14 @@ async def get_status_code(session: aiohttp.ClientSession, url: str, limit):
status_code = 200
except (aiohttp.ClientOSError, aiohttp.ClientConnectorError) as ex:
print(f"{ex} ({url})")
if "reset by peer" in str(ex):
if "reset by peer" in str(ex) or (not SUB_PAT.search(url) and not WWW_PAT.search(url)):
try:
await asyncio.sleep(1)
print(f"Checking the status of {url} again...")
resp = await session.get(f"http://{url}", allow_redirects=False)
newUrl = f"http://{url}"
if not SUB_PAT.search(url) and not WWW_PAT.search(url):
newUrl = f"http://www.{url}"
resp = await session.get(newUrl, allow_redirects=False)
status_code = resp.status
if status_code in (301, 302, 307, 308):
location = str(resp).split("Location': \'")[1].split("\'")[0]
Expand Down

0 comments on commit 7dcd352

Please sign in to comment.