MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / kill_switch

Function kill_switch

webapp_modern.py:10738–10890  ·  view source on GitHub ↗

EDUCATIONAL KILL SWITCH - Complete data erasure endpoint This endpoint provides a secure way to completely wipe all data after educational demonstrations. Deletion order: 1. Delete ragnar.db database file 2. Delete entire data/ folder 3. Delete entire Ragnar/ repository

()

Source from the content-addressed store, hash-verified

10736 wifi_network_data = read_wifi_network_data()
10737 current_time = datetime.now()
10738 arp_hosts = network_scan_cache.get('arp_hosts', {})
10739
10740 connectivity_info = {
10741 'timestamp': current_time.isoformat(),
10742 'summary': {
10743 'total_devices': len(wifi_network_data),
10744 'devices_in_arp': len(arp_hosts),
10745 'max_failed_pings': shared_data.config.get('network_max_failed_pings', 15) # Changed to 15 for more stability
10746 },
10747 'devices': []
10748 }
10749
10750 for entry in wifi_network_data:
10751 ip = entry.get('IPs', '').strip()
10752 if not ip:
10753 continue
10754
10755 device_info = {
10756 'ip': ip,
10757 'hostname': entry.get('Hostnames', ''),
10758 'mac': entry.get('MAC Address', ''),
10759 'alive': entry.get('Alive', 0),
10760 'failed_ping_count': entry.get('failed_ping_count', 0),
10761 'last_seen': entry.get('LastSeen', ''),
10762 'last_successful_ping': entry.get('last_successful_ping', ''),
10763 'last_ping_attempt': entry.get('last_ping_attempt', ''),
10764 'in_current_arp': ip in arp_hosts,
10765 'connectivity_status': 'stable' if entry.get('failed_ping_count', 0) == 0 else f"failing ({entry.get('failed_ping_count', 0)}/{shared_data.config.get('network_max_failed_pings', 15)})" # Changed to 15
10766 }
10767
10768 # Calculate time since last successful ping
10769 if device_info['last_successful_ping']:
10770 try:
10771 last_success = datetime.fromisoformat(device_info['last_successful_ping'])
10772 time_diff = current_time - last_success
10773 device_info['minutes_since_last_success'] = int(time_diff.total_seconds() / 60)
10774 except Exception:
10775 device_info['minutes_since_last_success'] = 'unknown'
10776 else:
10777 device_info['minutes_since_last_success'] = 'never'
10778
10779 connectivity_info['devices'].append(device_info)
10780
10781 # Sort by IP address
10782 connectivity_info['devices'].sort(key=lambda x: tuple(map(int, x['ip'].split('.'))))
10783
10784 response = jsonify(connectivity_info)
10785 response.headers['Cache-Control'] = 'no-cache, no-store, must-revalidate'
10786 response.headers['Pragma'] = 'no-cache'
10787 response.headers['Expires'] = '0'
10788 return response
10789
10790 except Exception as e:
10791 logger.error(f"Error getting connectivity tracking info: {e}")
10792 return jsonify({'error': str(e), 'timestamp': datetime.now().isoformat()}), 500
10793
10794@app.route('/api/debug/ai-service')
10795def get_ai_service_diagnostic():

Callers

nothing calls this directly

Calls 6

warningMethod · 0.80
criticalMethod · 0.80
errorMethod · 0.80
appendMethod · 0.80
getMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected