From ca0bd976894b7eb7c45a85f7ab6426ef4b2e3095 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Thu, 1 Apr 2021 18:51:42 +0200 Subject: [PATCH] new: Wait page when a capture is queued/ongoing --- website/web/__init__.py | 14 +++++++++++--- website/web/templates/tree_wait.html | 23 +++++++++++++++++++++++ 2 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 website/web/templates/tree_wait.html diff --git a/website/web/__init__.py b/website/web/__init__.py index 6c674150..1010428b 100644 --- a/website/web/__init__.py +++ b/website/web/__init__.py @@ -22,7 +22,8 @@ from werkzeug.security import generate_password_hash, check_password_hash from pymisp import MISPEvent -from lookyloo.helpers import get_homedir, update_user_agents, get_user_agents, get_config, get_taxonomies, load_cookies +from lookyloo.helpers import (get_homedir, update_user_agents, get_user_agents, get_config, + get_taxonomies, load_cookies, CaptureStatus) from lookyloo.lookyloo import Lookyloo, Indexing from lookyloo.exceptions import NoValidHarFile, MissingUUID from .proxied import ReverseProxied @@ -466,8 +467,15 @@ def tree(tree_uuid: str, node_uuid: Optional[str]=None): try: cache = lookyloo.capture_cache(tree_uuid) except MissingUUID: - flash(f'Unable to find this UUID ({tree_uuid}). The capture may still be ongoing, try again later.', 'error') - return redirect(url_for('index')) + status = lookyloo.get_capture_status(tree_uuid) + if status == CaptureStatus.UNKNOWN: + flash(f'Unable to find this UUID ({tree_uuid}).', 'error') + return redirect(url_for('index')) + elif status == CaptureStatus.QUEUED: + message = "The capture it queued, but didn't start yet." + elif status == CaptureStatus.ONGOING: + message = "The capture it ongoing." + return render_template('tree_wait.html', message=message, tree_uuid=tree_uuid) if not cache: flash('Invalid cache.', 'error') diff --git a/website/web/templates/tree_wait.html b/website/web/templates/tree_wait.html new file mode 100644 index 00000000..6dea1936 --- /dev/null +++ b/website/web/templates/tree_wait.html @@ -0,0 +1,23 @@ +{% extends "main.html" %} +{% block title %}Ongoing capture...{% endblock %} + +{% block content %} +
+
+
+
+
+
+
+
+ {{ message }} +
+ Please wait... +
+ +
+ + +
+ +{% endblock %}