Update main.py

This commit is contained in:
ilyastar9999
2025-12-03 10:50:18 +03:00
parent 8af9a1f04d
commit c5bcfab44c

View File

@@ -194,20 +194,26 @@ async def http_polling_listener():
while True: while True:
try: try:
async with aiohttp.ClientSession() as session: async with aiohttp.ClientSession() as session:
# ForcAD API endpoints for actual attack/flag data (not attack_data which is exploit credentials) # ForcAD real API endpoints (not Vue.js router paths)
# Try different possible paths # These should be accessed without /api prefix or with different structure
base_url = SCOREBOARD_API_URL.rstrip('/api').rstrip('/')
endpoints_to_try = [ endpoints_to_try = [
('/api/flag/submit', 'GET'), # Flag submission history # Try direct API access patterns
('/api/client/stolen_flags', 'GET'), # Stolen flags (f'{base_url}/flags', 'GET'),
('/api/client/flag_stats', 'GET'), # Flag statistics (f'{base_url}/stolen_flags', 'GET'),
('/api/game/status', 'GET'), # Game status with flags (f'{base_url}/flag_stats', 'GET'),
('/api/service/status', 'GET'), # Service status (f'{base_url}/game_state', 'GET'),
(f'{base_url}/scoreboard', 'GET'),
# Try with /api/ prefix variations
(f'{base_url}/api/flags/', 'GET'),
(f'{base_url}/api/stolen_flags/', 'GET'),
(f'{base_url}/api/game_state/', 'GET'),
] ]
data_found = False data_found = False
for endpoint_path, method in endpoints_to_try: for endpoint, method in endpoints_to_try:
endpoint = f"{SCOREBOARD_API_URL.rstrip('/api')}{endpoint_path}"
try: try:
async with session.get(endpoint, timeout=aiohttp.ClientTimeout(total=5)) as resp: async with session.get(endpoint, timeout=aiohttp.ClientTimeout(total=5)) as resp:
if resp.status == 200: if resp.status == 200:
@@ -525,29 +531,28 @@ async def debug_scoreboard():
results["websocket_status"] = f"unreachable: {str(e)}" results["websocket_status"] = f"unreachable: {str(e)}"
# Test HTTP endpoints - both HTML and API paths # Test HTTP endpoints - both HTML and API paths
base_url = SCOREBOARD_API_URL.rstrip('/api') base_url = SCOREBOARD_API_URL.rstrip('/api').rstrip('/')
endpoints = [ endpoints = [
"/api/flag/submit", f"{base_url}/flags",
"/api/client/stolen_flags", f"{base_url}/stolen_flags",
"/api/client/flag_stats", f"{base_url}/flag_stats",
"/api/game/status", f"{base_url}/game_state",
"/api/service/status", f"{base_url}/scoreboard",
"/api/attacks", f"{base_url}/api/flags/",
"/api/scoreboard", f"{base_url}/api/stolen_flags/",
"/api/teams", f"{base_url}/api/game_state/",
"/api/events" f"{base_url}/api/client/attack_data",
] ]
for endpoint in endpoints: for endpoint in endpoints:
url = f"{base_url}{endpoint}"
try: try:
async with session.get(url, timeout=aiohttp.ClientTimeout(total=5)) as resp: async with session.get(endpoint, timeout=aiohttp.ClientTimeout(total=5)) as resp:
content_type = resp.headers.get('Content-Type', '') content_type = resp.headers.get('Content-Type', '')
is_json = 'application/json' in content_type is_json = 'application/json' in content_type
is_html = 'text/html' in content_type is_html = 'text/html' in content_type
result = { result = {
"url": url, "url": endpoint,
"status": resp.status, "status": resp.status,
"reachable": resp.status == 200, "reachable": resp.status == 200,
"content_type": content_type, "content_type": content_type,
@@ -571,7 +576,7 @@ async def debug_scoreboard():
except Exception as e: except Exception as e:
results["endpoints_tested"].append({ results["endpoints_tested"].append({
"url": url, "url": endpoint,
"reachable": False, "reachable": False,
"error": str(e) "error": str(e)
}) })