mirror of
https://github.com/smittix/intercept.git
synced 2026-07-28 18:48:10 -07:00
Fix WiFi quick scan via agent and improve error messages
Agent fixes: - Accept 'success' status for quick scans (not just 'started') - WiFi quick scans return 'success' with results, not 'started' Controller fixes: - Pass through actual error messages from agent responses - Previously showed generic "Agent returned error: 400" - Now shows actual message like "Root privileges required for deep scan"
This commit is contained in:
+2
-1
@@ -3596,7 +3596,8 @@ class InterceptAgentHandler(BaseHTTPRequestHandler):
|
|||||||
|
|
||||||
if action == 'start':
|
if action == 'start':
|
||||||
result = mode_manager.start_mode(mode, body)
|
result = mode_manager.start_mode(mode, body)
|
||||||
status = 200 if result.get('status') == 'started' else 400
|
# Accept both 'started' and 'success' as valid (quick scans return 'success')
|
||||||
|
status = 200 if result.get('status') in ('started', 'success') else 400
|
||||||
self._send_json(result, status)
|
self._send_json(result, status)
|
||||||
elif action == 'stop':
|
elif action == 'stop':
|
||||||
result = mode_manager.stop_mode(mode)
|
result = mode_manager.stop_mode(mode)
|
||||||
|
|||||||
+22
-8
@@ -83,10 +83,17 @@ class AgentClient:
|
|||||||
except requests.Timeout:
|
except requests.Timeout:
|
||||||
raise AgentConnectionError(f"Request to agent timed out after {self.timeout}s")
|
raise AgentConnectionError(f"Request to agent timed out after {self.timeout}s")
|
||||||
except requests.HTTPError as e:
|
except requests.HTTPError as e:
|
||||||
raise AgentHTTPError(
|
# Try to extract error message from response body
|
||||||
f"Agent returned error: {e.response.status_code}",
|
error_msg = f"Agent returned error: {e.response.status_code}"
|
||||||
status_code=e.response.status_code
|
try:
|
||||||
)
|
error_data = e.response.json()
|
||||||
|
if 'message' in error_data:
|
||||||
|
error_msg = error_data['message']
|
||||||
|
elif 'error' in error_data:
|
||||||
|
error_msg = error_data['error']
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
raise AgentHTTPError(error_msg, status_code=e.response.status_code)
|
||||||
except requests.RequestException as e:
|
except requests.RequestException as e:
|
||||||
raise AgentHTTPError(f"Request failed: {e}")
|
raise AgentHTTPError(f"Request failed: {e}")
|
||||||
|
|
||||||
@@ -120,10 +127,17 @@ class AgentClient:
|
|||||||
except requests.Timeout:
|
except requests.Timeout:
|
||||||
raise AgentConnectionError(f"Request to agent timed out after {self.timeout}s")
|
raise AgentConnectionError(f"Request to agent timed out after {self.timeout}s")
|
||||||
except requests.HTTPError as e:
|
except requests.HTTPError as e:
|
||||||
raise AgentHTTPError(
|
# Try to extract error message from response body
|
||||||
f"Agent returned error: {e.response.status_code}",
|
error_msg = f"Agent returned error: {e.response.status_code}"
|
||||||
status_code=e.response.status_code
|
try:
|
||||||
)
|
error_data = e.response.json()
|
||||||
|
if 'message' in error_data:
|
||||||
|
error_msg = error_data['message']
|
||||||
|
elif 'error' in error_data:
|
||||||
|
error_msg = error_data['error']
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
raise AgentHTTPError(error_msg, status_code=e.response.status_code)
|
||||||
except requests.RequestException as e:
|
except requests.RequestException as e:
|
||||||
raise AgentHTTPError(f"Request failed: {e}")
|
raise AgentHTTPError(f"Request failed: {e}")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user