def refreshView(data): """Refresh the view filtered by client""" sessions = [] packets = [] users = [] filterHosts = True if data['topHosts'] == 'all': filterHosts = False print data['topHosts'] for session in Session.query.all(): if session.protocol in data['protocols']: if not filterHosts or session.hostSrc in data[ 'topHosts'] or session.hostDest in data['topHosts']: sessions.append(session.as_dict()) for packet in Packet.query.all(): if packet.protocol in data['protocols']: if not filterHosts or packet.hostSrc in data[ 'topHosts'] or packet.hostDest in data['topHosts']: packets.append(packet.as_dict()) for user in User.query.all(): exchanged = {} if not filterHosts or user.address in data['topHosts']: for protocol in data['protocols']: if user.exchanged['Protocole'].has_key(protocol): exchanged[protocol] = user.exchanged['Protocole'][protocol] if exchanged: user.exchanged['Protocole'] = exchanged users.append(user) treemap = get_treemap(users) newData = {'sessions': sessions, 'packets': packets, 'treemap': treemap} print newData["sessions"] socketio.emit('newData', json.dumps(newData))
def refreshView(data): """Refresh the view filtered by client""" sessions = [] packets = [] users = [] filterHosts = True if data["topHosts"] == "all": filterHosts = False print data["topHosts"] for session in Session.query.all(): if session.protocol in data["protocols"]: if not filterHosts or session.hostSrc in data["topHosts"] or session.hostDest in data["topHosts"]: sessions.append(session.as_dict()) for packet in Packet.query.all(): if packet.protocol in data["protocols"]: if not filterHosts or packet.hostSrc in data["topHosts"] or packet.hostDest in data["topHosts"]: packets.append(packet.as_dict()) for user in User.query.all(): exchanged = {} if not filterHosts or user.address in data["topHosts"]: for protocol in data["protocols"]: if user.exchanged["Protocole"].has_key(protocol): exchanged[protocol] = user.exchanged["Protocole"][protocol] if exchanged: user.exchanged["Protocole"] = exchanged users.append(user) treemap = get_treemap(users) newData = {"sessions": sessions, "packets": packets, "treemap": treemap} print newData["sessions"] socketio.emit("newData", json.dumps(newData))
def index(pcap=""): """Display home page""" treemap = [] users = User.query.all() stats = Stat.query.all() sessions = Session.query.all() packets = Packet.query.all() treemap = get_treemap(users) return render_template( "index.html", pcap=pcap, users=users, stats=stats, sessions=sessions, treemap=treemap, packets=packets )
def index(pcap=''): """Display home page""" treemap = [] users = User.query.all() stats = Stat.query.all() sessions = Session.query.all() packets = Packet.query.all() treemap = get_treemap(users) return render_template('index.html', pcap=pcap, users=users, stats=stats, sessions=sessions, treemap=treemap, packets=packets)