Преглед изворни кода

Expire shared keys every 60 minutes (#25)

Bryan Drewery пре 14 година
родитељ
комит
d59d346c87
2 измењених фајлова са 9 додато и 0 уклоњено
  1. 1 0
      doc/UPDATES
  2. 8 0
      src/mod/server.mod/server.c

+ 1 - 0
doc/UPDATES

@@ -15,6 +15,7 @@
     * Automatic re-key exchange after every message to avoid replay attacks (controllable with set 'fish-paranoid')
     * Set FiSH key via cmd_setkey and 'chanset fish-key'
     * Bot expires key exchange if there's no response in 7 seconds.
+    * Bot expires key-exchanged keys after 60 minutes.
   * When 'mdop' protection is on, re-op all previously opped clients automatically.
   * When 'mop' protection is on, deop all previously regular clients automatically.
   * Add './wraith -V' which will display the packconfig that the bot is using.

+ 8 - 0
src/mod/server.mod/server.c

@@ -1056,8 +1056,16 @@ static void server_secondly()
       for (size_t i = 0; i < fish_targets.length(); ++i) {
         const bd::String target(fish_targets[i]);
         fish_data_t* fishData = FishKeys[target];
+        bool should_delete = false;
         if (fishData->timestamp && !fishData->sharedKey && ((now - 7) >= fishData->timestamp)) {
           putlog(LOG_DEBUG, "*", "Deleting expired DH1080 FiSH exchange with %s", target.c_str());
+          should_delete = true;
+        } else if (fishData->timestamp && fishData->sharedKey.length() && ((now - 3600) >= fishData->timestamp)) {
+          putlog(LOG_DEBUG, "*", "Deleting expired (60 min) FiSH key with %s", target.c_str());
+          should_delete = true;
+        }
+
+        if (should_delete) {
           FishKeys.remove(target);
           delete fishData;
         }