From fa87e03222ba805853d8c4dfc74db2bdb9980abe Mon Sep 17 00:00:00 2001 From: dadav <33197631+dadav@users.noreply.github.com> Date: Fri, 17 Apr 2020 20:18:12 +0200 Subject: [PATCH] add max-lines --- pwnagotchi/defaults.toml | 1 + pwnagotchi/plugins/default/logtail.py | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pwnagotchi/defaults.toml b/pwnagotchi/defaults.toml index 937cca1..11835a2 100644 --- a/pwnagotchi/defaults.toml +++ b/pwnagotchi/defaults.toml @@ -110,6 +110,7 @@ main.plugins.led.patterns.peer_detected = "oo oo oo oo oo oo oo" main.plugins.led.patterns.peer_lost = "oo oo oo oo oo oo oo" main.plugins.logtail.enabled = false +main.plugins.logtail.max-lines = 10000 main.plugins.session-stats.enabled = true main.plugins.session-stats.save_directory = "/var/tmp/pwnagotchi/sessions/" diff --git a/pwnagotchi/plugins/default/logtail.py b/pwnagotchi/plugins/default/logtail.py index 3f633e1..adc9b20 100644 --- a/pwnagotchi/plugins/default/logtail.py +++ b/pwnagotchi/plugins/default/logtail.py @@ -207,12 +207,12 @@ TEMPLATE = """ } document.body.style.cursor = 'default'; } - {% endblock %} {% block content %}
+
@@ -254,6 +254,7 @@ class Logtail(plugins.Plugin): """ logging.info("Logtail plugin loaded.") + def on_webhook(self, path, request): if not self.ready: return "Plugin not ready" @@ -266,7 +267,7 @@ class Logtail(plugins.Plugin): with open(self.config['main']['log']['path']) as f: # https://stackoverflow.com/questions/39549426/read-multiple-lines-from-a-file-batch-by-batch/39549901#39549901 n = 1024 - for n_lines in iter(lambda: ''.join(islice(f, n)), ''): + for n_lines in iter(lambda: ''.join(islice(list(f)[-self.options.get('max-lines', 10000):], n)), ''): yield n_lines while True: yield f.readline()