From a5f9b9b2ee12dc637110d6561bb20ce67fcf84b1 Mon Sep 17 00:00:00 2001 From: Simone Margaritelli Date: Tue, 12 Nov 2019 23:56:59 +0100 Subject: [PATCH] new: encountered units --- pwnagotchi/grid.py | 4 +++ pwnagotchi/ui/web/handler.py | 16 +++++++++ pwnagotchi/ui/web/templates/inbox.html | 3 +- pwnagotchi/ui/web/templates/peers.html | 49 ++++++++++++++++++++++++++ 4 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 pwnagotchi/ui/web/templates/peers.html diff --git a/pwnagotchi/grid.py b/pwnagotchi/grid.py index c76db3a2..60589747 100644 --- a/pwnagotchi/grid.py +++ b/pwnagotchi/grid.py @@ -45,6 +45,10 @@ def get_advertisement_data(): return call("/mesh/data") +def memory(): + return call("/mesh/memory") + + def peers(): return call("/mesh/peers") diff --git a/pwnagotchi/ui/web/handler.py b/pwnagotchi/ui/web/handler.py index 21a2c7d2..e7a4dc1e 100644 --- a/pwnagotchi/ui/web/handler.py +++ b/pwnagotchi/ui/web/handler.py @@ -38,6 +38,7 @@ class Handler: # inbox self._app.add_url_rule('/inbox', 'inbox', self.with_auth(self.inbox)) self._app.add_url_rule('/inbox/profile', 'inbox_profile', self.with_auth(self.inbox_profile)) + self._app.add_url_rule('/inbox/peers', 'inbox_peers', self.with_auth(self.inbox_peers)) self._app.add_url_rule('/inbox/', 'show_message', self.with_auth(self.show_message)) self._app.add_url_rule('/inbox//', 'mark_message', self.with_auth(self.mark_message)) self._app.add_url_rule('/inbox/new', 'new_message', self.with_auth(self.new_message)) @@ -108,6 +109,21 @@ class Handler: data=data, error=error) + def inbox_peers(self): + peers = {} + error = None + + try: + peers = grid.memory() + except Exception as e: + logging.exception('error while reading pwngrid peers') + error = str(e) + + return render_template('peers.html', + name=pwnagotchi.name(), + peers=peers, + error=error) + def show_message(self, id): message = {} error = None diff --git a/pwnagotchi/ui/web/templates/inbox.html b/pwnagotchi/ui/web/templates/inbox.html index 1fd998c3..2132d6d3 100644 --- a/pwnagotchi/ui/web/templates/inbox.html +++ b/pwnagotchi/ui/web/templates/inbox.html @@ -36,7 +36,8 @@ diff --git a/pwnagotchi/ui/web/templates/peers.html b/pwnagotchi/ui/web/templates/peers.html new file mode 100644 index 00000000..dabeb08d --- /dev/null +++ b/pwnagotchi/ui/web/templates/peers.html @@ -0,0 +1,49 @@ + + + + + + + {{ name }} friends + + + + + + + + + + + + + +
+ +
+
+ +
+
+ + + +
+ + +