Browse Source

set user defined params before defaults

Jens Keim 5 years ago
parent
commit
844d351481
2 changed files with 6 additions and 2 deletions
  1. 4 0
      code/Attack/BaseAttack.py
  2. 2 2
      code/Core/AttackController.py

+ 4 - 0
code/Attack/BaseAttack.py

@@ -368,6 +368,10 @@ class BaseAttack(metaclass=abc.ABCMeta):
             print("ERROR: Parameter " + param + " is not supported by ID2T.")
             sys.exit(-1)
 
+        # if parameter is already specified, stop
+        if param_name in self.params.keys():
+            return
+
         # Get parameter type of attack's required_params
         param_type = self.supported_params.get(param_name)
 

+ 2 - 2
code/Core/AttackController.py

@@ -116,8 +116,6 @@ class AttackController:
         if seed is not None:
             self.current_attack.set_seed(seed=seed)
 
-        self.current_attack.init_params()
-
         # Unset the user-specified-flag for all parameters set in init_params
         for k, v in self.current_attack.params.items():
             self.current_attack.params[k] = self.current_attack.ValuePair(v.value, False)
@@ -168,6 +166,8 @@ class AttackController:
         else:
             attack_note = "This attack used only (random) default parameters."
 
+        self.current_attack.init_params()
+
         # Write attack into pcap file
         print("Generating attack packets...", end=" ")
         sys.stdout.flush()  # force python to print text immediately