From 00582be3746c4adc23aed00797040a2902ffc9aa Mon Sep 17 00:00:00 2001
From: Simone Margaritelli <evilsocket@gmail.com>
Date: Mon, 7 Oct 2019 10:25:46 +0200
Subject: [PATCH] new: reporting session data to the api

---
 pwnagotchi/plugins/default/api.py | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/pwnagotchi/plugins/default/api.py b/pwnagotchi/plugins/default/api.py
index 480f07c..5828085 100644
--- a/pwnagotchi/plugins/default/api.py
+++ b/pwnagotchi/plugins/default/api.py
@@ -7,6 +7,7 @@ __description__ = 'This plugin signals the unit cryptographic identity to api.pw
 import logging
 import json
 import requests
+import subprocess
 import pwnagotchi
 from pwnagotchi.utils import StatusFile
 
@@ -27,6 +28,7 @@ def on_internet_available(ui, keypair, config, log):
 
     try:
         logging.info("api: signign enrollment request ...")
+
         identity = "%s@%s" % (pwnagotchi.name(), keypair.fingerprint)
         _, signature_b64 = keypair.sign(identity)
 
@@ -34,7 +36,16 @@ def on_internet_available(ui, keypair, config, log):
         enroll = {
             'identity': identity,
             'public_key': keypair.pub_key_pem_b64,
-            'signature': signature_b64
+            'signature': signature_b64,
+            'data': {
+                'duration': log.duration,
+                'epochs': log.epochs,
+                'train_epochs': log.train_epochs,
+                'avg_reward': log.avg_reward,
+                'min_reward': log.min_reward,
+                'max_reward': log.max_reward,
+                'uname': subprocess.getoutput("uname -a")
+            }
         }
 
         logging.info("api: enrolling unit to %s ..." % api_address)