- /*
- // Contains all ON events: hostname -> sequence identifier -> list of conversations with that sequence
- Map<String, Map<String, List<Conversation>>> ons = new HashMap<>();
- // Contains all OFF events: hostname -> sequence identifier -> list of conversations with that sequence
- Map<String, Map<String, List<Conversation>>> offs = new HashMap<>();
- userActionsToConvsByHostname.forEach((ua, hostnameToConvs) -> {
- Map<String, Map<String, List<Conversation>>> outer = ua.getType() == Type.TOGGLE_ON ? ons : offs;
- hostnameToConvs.forEach((host, convs) -> {
- Map<String, List<Conversation>> seqsToConvs = TcpConversationUtils.
- groupConversationsByPacketSequence(convs, verbose);
- outer.merge(host, seqsToConvs, (oldMap, newMap) -> {
- newMap.forEach((sequence, cs) -> oldMap.merge(sequence, cs, (list1, list2) -> {
- list1.addAll(list2);
- return list1;
- }));
- return oldMap;
- });
- });
- });
- */
+
+// // Contains all ON events: hostname -> sequence identifier -> list of conversations with that sequence
+// Map<String, Map<String, List<Conversation>>> ons = new HashMap<>();
+// // Contains all OFF events: hostname -> sequence identifier -> list of conversations with that sequence
+// Map<String, Map<String, List<Conversation>>> offs = new HashMap<>();
+// userActionsToConvsByHostname.forEach((ua, hostnameToConvs) -> {
+// Map<String, Map<String, List<Conversation>>> outer = ua.getType() == Type.TOGGLE_ON ? ons : offs;
+// hostnameToConvs.forEach((host, convs) -> {
+// Map<String, List<Conversation>> seqsToConvs = TcpConversationUtils.
+// groupConversationsByPacketSequence(convs, verbose);
+// outer.merge(host, seqsToConvs, (oldMap, newMap) -> {
+// newMap.forEach((sequence, cs) -> oldMap.merge(sequence, cs, (list1, list2) -> {
+// list1.addAll(list2);
+// return list1;
+// }));
+// return oldMap;
+// });
+// });
+// });
+//
+// System.out.println("==== ON ====");
+// // Print out all the pairs into a file for ON events
+// File fileOnEvents = new File(onPairsPath);
+// PrintWriter pwOn = null;
+// try {
+// pwOn = new PrintWriter(fileOnEvents);
+// } catch(Exception ex) {
+// ex.printStackTrace();
+// }
+// for(Map.Entry<String, Map<String, List<Conversation>>> entry : ons.entrySet()) {
+// Map<String, List<Conversation>> seqsToConvs = entry.getValue();
+// for(Map.Entry<String, List<Conversation>> entryConv : seqsToConvs.entrySet()) {
+// List<Conversation> listConv = entryConv.getValue();
+// // Just get the first Conversation because all Conversations in this group
+// // should have the same pairs of Application Data.
+// for(Conversation conv : listConv) {
+// // Process only if it is a TLS packet
+// if (conv.isTls()) {
+// List<PcapPacketPair> tlsAppDataList = TcpConversationUtils.extractTlsAppDataPacketPairs(conv);
+// for(PcapPacketPair pair: tlsAppDataList) {
+// System.out.println(PrintUtils.toCsv(pair, dnsMap));
+// pwOn.println(PrintUtils.toCsv(pair, dnsMap));
+// }
+// } else { // Non-TLS conversations
+// List<PcapPacketPair> packetList = TcpConversationUtils.extractPacketPairs(conv);
+// for(PcapPacketPair pair: packetList) {
+// System.out.println(PrintUtils.toCsv(pair, dnsMap));
+// pwOn.println(PrintUtils.toCsv(pair, dnsMap));
+// }
+// }
+// }
+// }
+// }
+// pwOn.close();
+//
+// System.out.println("==== OFF ====");
+// // Print out all the pairs into a file for ON events
+// File fileOffEvents = new File(offPairsPath);
+// PrintWriter pwOff = null;
+// try {
+// pwOff = new PrintWriter(fileOffEvents);
+// } catch(Exception ex) {
+// ex.printStackTrace();
+// }
+// for(Map.Entry<String, Map<String, List<Conversation>>> entry : offs.entrySet()) {
+// Map<String, List<Conversation>> seqsToConvs = entry.getValue();
+// for(Map.Entry<String, List<Conversation>> entryConv : seqsToConvs.entrySet()) {
+// List<Conversation> listConv = entryConv.getValue();
+// // Just get the first Conversation because all Conversations in this group
+// // should have the same pairs of Application Data.
+// for(Conversation conv : listConv) {
+// // Process only if it is a TLS packet
+// if (conv.isTls()) {
+// List<PcapPacketPair> tlsAppDataList = TcpConversationUtils.extractTlsAppDataPacketPairs(conv);
+// for(PcapPacketPair pair: tlsAppDataList) {
+// System.out.println(PrintUtils.toCsv(pair, dnsMap));
+// pwOff.println(PrintUtils.toCsv(pair, dnsMap));
+// }
+// } else { // Non-TLS conversations
+// List<PcapPacketPair> packetList = TcpConversationUtils.extractPacketPairs(conv);
+// for (PcapPacketPair pair : packetList) {
+// System.out.println(PrintUtils.toCsv(pair, dnsMap));
+// pwOff.println(PrintUtils.toCsv(pair, dnsMap));
+// }
+// }
+// }
+// }
+// }
+// pwOff.close();
+