40 lines
1.2 KiB
Python
40 lines
1.2 KiB
Python
|
|
#!/usr/bin/env python3
|
||
|
|
"""
|
||
|
|
Test the fast discovery service
|
||
|
|
"""
|
||
|
|
import asyncio
|
||
|
|
import sys
|
||
|
|
import os
|
||
|
|
import logging
|
||
|
|
|
||
|
|
# Add src to path
|
||
|
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'src'))
|
||
|
|
|
||
|
|
# Set up logging
|
||
|
|
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
||
|
|
|
||
|
|
from discovery.protocol_discovery_fast import discovery_service
|
||
|
|
|
||
|
|
async def test_discovery_fast():
|
||
|
|
"""Test fast discovery service"""
|
||
|
|
print("Starting fast discovery test...")
|
||
|
|
|
||
|
|
try:
|
||
|
|
# Test full discovery
|
||
|
|
print("\nTesting full discovery...")
|
||
|
|
result = await discovery_service.discover_all_protocols("fast_test_scan")
|
||
|
|
|
||
|
|
print(f"\nDiscovery completed in {result.scan_duration:.2f} seconds!")
|
||
|
|
print(f"Total discovered endpoints: {len(result.discovered_endpoints)}")
|
||
|
|
print(f"Errors: {result.errors}")
|
||
|
|
|
||
|
|
for endpoint in result.discovered_endpoints:
|
||
|
|
print(f" - {endpoint.protocol_type}: {endpoint.address}")
|
||
|
|
|
||
|
|
except Exception as e:
|
||
|
|
print(f"Discovery failed: {e}")
|
||
|
|
import traceback
|
||
|
|
traceback.print_exc()
|
||
|
|
|
||
|
|
if __name__ == "__main__":
|
||
|
|
asyncio.run(test_discovery_fast())
|