This commit is contained in:
Ground-Zerro
2024-03-25 02:44:40 +11:00
parent fc66730bcf
commit 5e1b36a2a6
2 changed files with 9 additions and 7 deletions

View File

@@ -28,3 +28,4 @@ type = ip
# Gateway address - used only if option "type" set to 'win'
# if not specified the default value will be used (0.0.0.0.0)
gateway = 0.0.0.0

11
main.py
View File

@@ -1,4 +1,4 @@
import os
import os
import requests
import dns.resolver
from concurrent.futures import ThreadPoolExecutor
@@ -27,6 +27,7 @@ urls = {
# Function to resolve DNS
def resolve_dns_and_write(service, url, unique_ips_all_services, include_cloudflare, threads):
try:
print(f"Загрузка данных - {service}")
response = requests.get(url)
response.raise_for_status()
dns_names = response.text.split('\n')
@@ -52,10 +53,12 @@ def resolve_dns_and_write(service, url, unique_ips_all_services, include_cloudfl
futures.append(executor.submit(resolve_domain, resolver, domain, unique_ips_current_service, unique_ips_all_services, cloudflare_ips))
return '\n'.join(unique_ips_current_service) + '\n'
print(f"Список IP-адресов для платформы {service} создан.")
except Exception as e:
print(f"Не удалось загрузить список доменных имен сервиса: {service}.\n")
print(f"Не удалось сопоставить IP адреса {service} его доменным именам.", e)
return ""
# Function to get Cloudflare IP addresses
def get_cloudflare_ips():
try:
@@ -119,11 +122,9 @@ def read_config(filename):
return service, threads, outfilename, cloudflare, type_, gateway, run_command
else:
print("Секция 'DomainMapper' отсутствует в конфигурационном файле. Будут использованы значения по умолчанию.")
return default_values
except Exception as e:
print("Ошибка при чтении конфигурационного файла:", e)
return default_values
# Main function
@@ -182,7 +183,7 @@ def main():
print("\nПроверка завершена.")
print(f"Проверено DNS имен: {total_resolved_domains + total_errors}")
print(f"Сопоставлено IP адресов доменам: {total_resolved_domains}")
print(f"Не удалось сопоставить доменов IP адресу: {total_errors}")
print(f"Не удалось обработать доменных имен: {total_errors}")
print("Результаты проверки сохранены в файл:", outfilename)
# Executing the command after the program is completed, if it is specified in the configuration file