new awesome build

This commit is contained in:
Антон
2026-01-28 22:37:47 +03:00
parent 848646003c
commit fcb8f6bac7
119 changed files with 7291 additions and 5575 deletions

View File

@@ -0,0 +1,29 @@
import requests
import logging
from typing import Optional
logger = logging.getLogger(__name__)
def get_public_ip() -> str:
"""
Detects public IP using external services.
Falls back to 127.0.0.1 on failure.
"""
services = [
"https://api.ipify.org",
"https://ifconfig.me/ip",
"https://icanhazip.com",
]
for service in services:
try:
response = requests.get(service, timeout=3)
if response.status_code == 200:
ip = response.text.strip()
# Basic validation could be added here
return ip
except requests.RequestException:
continue
logger.warning("Could not detect public IP, defaulting to 127.0.0.1")
return "127.0.0.1"