Browse Source

Merge branch 'master' of c3pb.de:freifunk-pb/status-daemon

Helge Jung 9 years ago
parent
commit
e006978657
2 changed files with 14 additions and 4 deletions
  1. 13 3
      ffstatus/basestorage.py
  2. 1 1
      ffstatus/server.py

+ 13 - 3
ffstatus/basestorage.py

@@ -78,7 +78,8 @@ class BaseStorage(object):
 
         nodes = 0
         nodes_active = 0
-        clients = 0
+        sum_clients = 0
+        clients = set()
 
         for item_id in self.data:
             if item_id.startswith('__'):
@@ -87,12 +88,21 @@ class BaseStorage(object):
             node = self.data[item_id]
 
             nodes += 1
-            clients += node.get('clientcount', 0)
             if self.get_nodestatus(item_id) == 'active':
                 nodes_active += 1
 
+            sum_clients += node.get('clientcount', 0)
+            nodemacs = [x for x in node.get('macs', [])]
+            if 'mac' in node:
+		nodemacs.add(node['mac'])
+            for client in node.get('clients', []):
+		if client in nodemacs:
+			continue
+                clients.add(client)
+
         return {
-            'clients': clients,
+            'clients_sum': sum_clients,
+            'clients_unique': len(clients),
             'nodes': nodes,
             'nodes_active': nodes_active,
         }

+ 1 - 1
ffstatus/server.py

@@ -359,7 +359,7 @@ class BatcaveHttpRequestHandler(BaseHTTPRequestHandler):
                     key, peername, remote, gateway, timestamp)
 
             elif action == 'disestablish':
-                self.server.storage.log_vpn_connect(key, gateway, timestamp)
+                self.server.storage.log_vpn_disconnect(key, gateway, timestamp)
 
             else:
                 self.logger.error('Unknown VPN action \'%s\' not filtered.',