Ver Fonte

Refactor retrieval of router, i.e. most used, MAC address (2)

The problem with the first commit was that the file was copied
from somewhere else that did not have the latest version of it.
Now this version is equal (except for the imports) to the latest
one residing on the develop branch.
dustin.born há 6 anos atrás
pai
commit
b52010af00
1 ficheiros alterados com 8 adições e 2 exclusões
  1. 8 2
      code/ID2TLib/PcapAddressOperations.py

+ 8 - 2
code/ID2TLib/PcapAddressOperations.py

@@ -16,6 +16,13 @@ class PcapAddressOperations():
         """
         self.statistics = statistics
         self.UNCERTAIN_IPSPACE_MULTIPLIER = uncertain_ip_mult
+
+        stat_result = self.statistics.process_db_query("most_used(macAddress)", print_results=False)
+        if isinstance(stat_result, list):
+            self.probable_router_mac = choice(stat_result)
+        else:
+            self.probable_router_mac = stat_result
+
         self._init_ipaddress_ops()
 
     def get_probable_router_mac(self):
@@ -23,8 +30,7 @@ class PcapAddressOperations():
         Returns the most probable router MAC address based on the most used MAC address in the statistics.
         :return: the MAC address
         """
-        self.probable_router_mac, count = self.statistics.process_db_query("most_used(macAddress)", print_results=False)[0]
-        return self.probable_router_mac     # and count as a measure of certainty?
+        return self.probable_router_mac
 
     def pcap_contains_priv_ips(self):
         """