Fix jwt-token

This commit is contained in:
2025-09-07 12:18:29 +02:00
parent ca47019783
commit c2851a1e74

View File

@@ -7,7 +7,18 @@ a long-distance approach from undetectable range to directly overhead.
Test Scenario: Test Scenario:
- Starts 50km away (beyond detection range) - Starts 50km away (beyond detection range)
- Slowly approaches target device - Slowly approaches target device
- Triggers critical alerts as it enters detection range - Triggers critical alerts as print(f"🛫 {drone_name} Starting Distance: {float(start_distance):.1f}km from device")
print(f"📍 Device Location: {target_lat:.6f}, {target_lon:.6f}")
# Verify starting position is undetectable
if is_detectable(start_distance):
print("⚠️ WARNING: Starting position is within detection range!")
else:
print("✅ Starting position confirmed undetectable")
print("\n" + "=" * 70)
print(f"STARTING {drone_name.upper()} APPROACH SIMULATION")
print("=" * 70)etection range
- Ends with drone hovering directly above target - Ends with drone hovering directly above target
""" """
@@ -90,6 +101,85 @@ def get_auth_headers():
MAX_DETECTION_RANGE_KM = 25.0 # Maximum range for drone detection MAX_DETECTION_RANGE_KM = 25.0 # Maximum range for drone detection
MIN_RSSI_THRESHOLD = -95 # Minimum RSSI for detection MIN_RSSI_THRESHOLD = -95 # Minimum RSSI for detection
# Drone types mapping (matches GuessedDroneType enum)
DRONE_TYPES = {
0: "None",
1: "Unknown",
2: "Orlan",
3: "Zala",
4: "Eleron",
5: "ZalaLancet",
6: "Lancet",
7: "FPV_CrossFire",
8: "FPV_ELRS",
9: "MaybeOrlan",
10: "MaybeZala",
11: "MaybeLancet",
12: "MaybeEleron",
13: "DJI",
14: "Supercam",
15: "MaybeSupercam",
16: "REB",
17: "CryptoOrlan",
18: "DJIe"
}
def select_drone_type():
"""Allow user to select drone type for simulation"""
print("\n" + "=" * 50)
print("🚁 DRONE TYPE SELECTION")
print("=" * 50)
print("Available drone types:")
# Group by category for better display
military_types = [(k, v) for k, v in DRONE_TYPES.items() if v in ["Orlan", "Zala", "Eleron", "ZalaLancet", "Lancet", "CryptoOrlan"]]
maybe_types = [(k, v) for k, v in DRONE_TYPES.items() if v.startswith("Maybe")]
fpv_types = [(k, v) for k, v in DRONE_TYPES.items() if v.startswith("FPV_")]
commercial_types = [(k, v) for k, v in DRONE_TYPES.items() if v in ["DJI", "DJIe", "Supercam", "MaybeSupercam"]]
other_types = [(k, v) for k, v in DRONE_TYPES.items() if v in ["None", "Unknown", "REB"]]
print("\n🎖️ MILITARY DRONES:")
for drone_id, name in military_types:
print(f" {drone_id:2d}: {name}")
print("\n🏢 COMMERCIAL DRONES:")
for drone_id, name in commercial_types:
print(f" {drone_id:2d}: {name}")
print("\n🎮 FPV DRONES:")
for drone_id, name in fpv_types:
print(f" {drone_id:2d}: {name}")
print("\n❓ UNCERTAIN TYPES:")
for drone_id, name in maybe_types:
print(f" {drone_id:2d}: {name}")
print("\n🔧 OTHER:")
for drone_id, name in other_types:
print(f" {drone_id:2d}: {name}")
print("\n" + "=" * 50)
while True:
try:
choice = input(f"Select drone type (0-{max(DRONE_TYPES.keys())}) [default: 2-Orlan]: ").strip()
if choice == "":
return 2 # Default to Orlan
drone_type = int(choice)
if drone_type in DRONE_TYPES:
print(f"✅ Selected: {DRONE_TYPES[drone_type]} (Type {drone_type})")
return drone_type
else:
print(f"❌ Invalid choice. Please select 0-{max(DRONE_TYPES.keys())}")
except ValueError:
print("❌ Please enter a valid number")
except KeyboardInterrupt:
print("\n⚠️ Using default: Orlan (Type 2)")
return 2
def haversine_distance(lat1, lon1, lat2, lon2): def haversine_distance(lat1, lon1, lat2, lon2):
"""Calculate distance between two points in kilometers""" """Calculate distance between two points in kilometers"""
R = 6371 # Earth's radius in kilometers R = 6371 # Earth's radius in kilometers
@@ -144,7 +234,7 @@ def fetch_devices():
print(f"Error fetching devices: {e}") print(f"Error fetching devices: {e}")
return [] return []
def send_detection(device, distance_km, step, total_steps): def send_detection(device, distance_km, step, total_steps, drone_type=2):
"""Send a detection to the API using EXACT standard payload format""" """Send a detection to the API using EXACT standard payload format"""
# Ensure distance_km is a float # Ensure distance_km is a float
distance_km = float(distance_km) distance_km = float(distance_km)
@@ -157,9 +247,9 @@ def send_detection(device, distance_km, step, total_steps):
"geo_lat": float(device["geo_lat"]), # Device location "geo_lat": float(device["geo_lat"]), # Device location
"geo_lon": float(device["geo_lon"]), # Device location "geo_lon": float(device["geo_lon"]), # Device location
"device_timestamp": int(time.time() * 1000), # Current timestamp in milliseconds "device_timestamp": int(time.time() * 1000), # Current timestamp in milliseconds
"drone_type": 1, # Orlan/Military type "drone_type": drone_type, # Selected drone type
"rssi": int(rssi), # RSSI indicates distance from device "rssi": int(rssi), # RSSI indicates distance from device
"freq": 24, # Orlan operates on 2.4 GHz (24 = 2400 MHz) "freq": 24, # Most drones operate on 2.4 GHz (24 = 2400 MHz)
"drone_id": 2000 + step # Unique drone ID for tracking "drone_id": 2000 + step # Unique drone ID for tracking
} }
@@ -178,15 +268,15 @@ def send_detection(device, distance_km, step, total_steps):
return False return False
def run_orlan_detection_test(): def run_orlan_detection_test():
"""Run the comprehensive Orlan detection test""" """Run the comprehensive drone detection test"""
print("=" * 70) print("=" * 70)
print("🚨 ORLAN MILITARY DRONE DETECTION TEST") print("<EFBFBD> DRONE DETECTION SIMULATION TEST")
print("=" * 70) print("=" * 70)
print("Test Scenario:") print("Test Scenario:")
print("• Starting position: 50km away (undetectable)") print("• Starting position: 50km away (undetectable)")
print("• Approach pattern: Straight line to target") print("• Approach pattern: Gradual approach to device")
print("• Detection threshold: ~25km range") print("• Detection threshold: ~25km range")
print("• Critical alerts: <5km from target") print("• Critical alerts: <5km from device")
print("• End position: Directly overhead (0m)") print("• End position: Directly overhead (0m)")
print("=" * 70) print("=" * 70)
print(f"🔗 API Endpoint: {API_BASE_URL}") print(f"🔗 API Endpoint: {API_BASE_URL}")
@@ -194,6 +284,10 @@ def run_orlan_detection_test():
print("⚠️ AUTHENTICATION DISABLED - Running in local test mode") print("⚠️ AUTHENTICATION DISABLED - Running in local test mode")
print() print()
# Select drone type for simulation
selected_drone_type = select_drone_type()
drone_name = DRONE_TYPES[selected_drone_type]
# Authenticate first (unless skipped) # Authenticate first (unless skipped)
if not SKIP_AUTH and not authenticate(): if not SKIP_AUTH and not authenticate():
print("❌ Authentication failed. Cannot proceed with test.") print("❌ Authentication failed. Cannot proceed with test.")
@@ -278,10 +372,10 @@ def run_orlan_detection_test():
# Send detection only if within detectable range # Send detection only if within detectable range
if detectable: if detectable:
if not detection_started: if not detection_started:
print(f"\n🔍 FIRST DETECTION at {float(distance_km):.1f}km - Orlan has entered detection range!") print(f"\n🔍 FIRST DETECTION at {float(distance_km):.1f}km - {drone_name} has entered detection range!")
detection_started = True detection_started = True
success = send_detection(target_device, distance_km, step, total_steps) success = send_detection(target_device, distance_km, step, total_steps, selected_drone_type)
if not success: if not success:
print(f"❌ Failed to send detection at step {step}") print(f"❌ Failed to send detection at step {step}")
@@ -292,9 +386,9 @@ def run_orlan_detection_test():
print(f"🚨 CRITICAL ALERT THRESHOLD REACHED at {float(distance_km):.1f}km!") print(f"🚨 CRITICAL ALERT THRESHOLD REACHED at {float(distance_km):.1f}km!")
critical_alerts_started = True critical_alerts_started = True
elif distance_km <= 1: elif distance_km <= 1:
print(f"🔥 IMMEDIATE THREAT: Orlan within {float(distance_km):.1f}km!") print(f"🔥 IMMEDIATE THREAT: {drone_name} within {float(distance_km):.1f}km!")
elif distance_km <= 0.1: elif distance_km <= 0.1:
print(f"💥 DIRECTLY OVERHEAD: Orlan at {float(distance_km)*1000:.0f}m altitude!") print(f"💥 DIRECTLY OVERHEAD: {drone_name} at {float(distance_km)*1000:.0f}m altitude!")
else: else:
# Outside detection range # Outside detection range
print(f"📡 Step {step}/{total_steps}: Distance={float(distance_km):.1f}km (undetectable, RSSI={float(rssi_from_distance(distance_km)):.0f}dBm)") print(f"📡 Step {step}/{total_steps}: Distance={float(distance_km):.1f}km (undetectable, RSSI={float(rssi_from_distance(distance_km)):.0f}dBm)")
@@ -312,7 +406,7 @@ def run_orlan_detection_test():
time.sleep(delay) time.sleep(delay)
print("\n" + "=" * 70) print("\n" + "=" * 70)
print("🚨 ORLAN DETECTION TEST COMPLETED") print(f"<EFBFBD> {drone_name.upper()} DETECTION TEST COMPLETED")
print("=" * 70) print("=" * 70)
print("Test Summary:") print("Test Summary:")
print(f"• Starting distance: {float(start_distance):.1f}km (undetectable)") print(f"• Starting distance: {float(start_distance):.1f}km (undetectable)")
@@ -320,12 +414,13 @@ def run_orlan_detection_test():
print(f"• Critical alerts triggered: <5km") print(f"• Critical alerts triggered: <5km")
print(f"• Final position: Directly overhead") print(f"• Final position: Directly overhead")
print(f"• Target device: {target_device['name']}") print(f"• Target device: {target_device['name']}")
print(f"• Drone type tested: {drone_name} (Type {selected_drone_type})")
print(f"• Total simulation steps: {total_steps}") print(f"• Total simulation steps: {total_steps}")
print("") print("")
print("Expected Results:") print("Expected Results:")
print("✅ No detections sent while >25km away") print("✅ No detections sent while >25km away")
print("✅ First detection when entering ~25km range") print("✅ First detection when entering ~25km range")
print("✅ Critical alerts triggered for Orlan type (drone_type=1)") print(f"✅ Critical alerts triggered for {drone_name} type (drone_type={selected_drone_type})")
print("✅ All alerts escalated regardless of distance/RSSI") print("✅ All alerts escalated regardless of distance/RSSI")
print("✅ Real-time tracking visible on dashboard") print("✅ Real-time tracking visible on dashboard")
print("=" * 70) print("=" * 70)
@@ -334,6 +429,6 @@ if __name__ == "__main__":
try: try:
run_orlan_detection_test() run_orlan_detection_test()
except KeyboardInterrupt: except KeyboardInterrupt:
print("\n\n⚠️ Orlan detection test interrupted by user") print("\n\n⚠️ Drone detection test interrupted by user")
except Exception as e: except Exception as e:
print(f"\n❌ Error during Orlan detection test: {e}") print(f"\n❌ Error during drone detection test: {e}")