Explorar o código

Fix bug happening during selection of ID roles

Before, the assumption was that every response had to have a
request preceeding it. Since this turned out not to be the case,
the code had to be modified accordingly.
dustin.born %!s(int64=6) %!d(string=hai) anos
pai
achega
95baf2b361
Modificáronse 1 ficheiros con 4 adicións e 3 borrados
  1. 4 3
      code/ID2TLib/Botnet/CommunicationProcessor.py

+ 4 - 3
code/ID2TLib/Botnet/CommunicationProcessor.py

@@ -151,12 +151,13 @@ class CommunicationProcessor():
                 # convert the abstract message into a message object to handle it better
                 msg_str = "{0}-{1}".format(id_dst, id_src)
                 # find the request message ID for this response and set its reference index
-                refer_idx = prev_reqs[msg_str]
-                msgs[refer_idx].refer_msg_id = msg_id
+                refer_idx = prev_reqs.get(msg_str, -1)
+                if refer_idx != -1:
+                    msgs[refer_idx].refer_msg_id = msg_id
+                    del(prev_reqs[msg_str])
                 msg = Message(msg_id, id_src, id_dst, msg_type, time, refer_idx, lineno)
                 msgs.append(msg)
                 # remove the request to this response from storage
-                del(prev_reqs[msg_str])
                 msg_id += 1
 
             elif msg_type == MessageType.TIMEOUT and id_src in local_init_ids and not self.nat: