Fix agent mode issues and WiFi deep scan polling

Agent fixes:
- Fix Ctrl+C hang by running cleanup in background thread
- Add force-exit on double Ctrl+C
- Improve exception handling in output reader threads to prevent
  bad file descriptor errors on shutdown
- Reduce cleanup timeouts for faster shutdown

Controller/UI fixes:
- Add URL validation for agent registration (check port, protocol)
- Show helpful message when agent is unreachable during registration
- Clarify API key field label (reserved for future use)
- Add client-side URL validation with user-friendly error messages

WiFi agent mode fixes:
- Add polling fallback for deep scan when push mode is disabled
- Polls /controller/agents/{id}/wifi/data every 2 seconds
- Detect running scans when switching to an agent
- Fix scan_mode detection (agent uses params.scan_type)
This commit is contained in:
cemaxecuter
2026-01-31 07:48:08 -05:00
parent 5f588a5513
commit f0cc396a6b
6 changed files with 487 additions and 68 deletions

View File

@@ -337,6 +337,7 @@
<div class="form-group">
<label for="agentApiKey">API Key (optional)</label>
<input type="text" id="agentApiKey" placeholder="shared-secret">
<small style="color: #888; font-size: 11px;">Required if agent has push mode enabled with API key</small>
</div>
</div>
<div class="form-row">
@@ -455,6 +456,22 @@
const apiKey = document.getElementById('agentApiKey').value.trim();
const description = document.getElementById('agentDescription').value.trim();
// Validate URL format
try {
const url = new URL(baseUrl);
if (!url.port && !baseUrl.includes(':80') && !baseUrl.includes(':443')) {
showToast('URL should include a port (e.g., http://192.168.1.50:8020)', 'error');
return;
}
if (url.protocol !== 'http:' && url.protocol !== 'https:') {
showToast('URL must start with http:// or https://', 'error');
return;
}
} catch (e) {
showToast('Invalid URL format. Use: http://IP_ADDRESS:PORT', 'error');
return;
}
try {
const response = await fetch('/controller/agents', {
method: 'POST',