Browse Source

r9389@Kushana: nickm | 2006-10-25 17:46:16 -0400
Add a CLEARDNSCACHE signal to clear the client-side DNS cache.


svn:r8829

Nick Mathewson 17 years ago
parent
commit
3fbb292bff
5 changed files with 16 additions and 2 deletions
  1. 2 0
      ChangeLog
  2. 5 2
      doc/control-spec.txt
  3. 2 0
      src/or/control.c
  4. 6 0
      src/or/main.c
  5. 1 0
      src/or/or.h

+ 2 - 0
ChangeLog

@@ -30,6 +30,8 @@ Changes in version 0.1.2.3-alpha - 2006-10-??
       has changed.
     - Add a GETINFO events/names and GETINFO features/names so controllers
       can tell which events and features are supported.
+    - A new CLEARDNSCACHE signal to allow controllers to clear the
+      client-side DNS cache without expiring circuits.
 
   o Security bugfixes:
     - When the user sends a NEWNYM signal, clear the client-side DNS

+ 5 - 2
doc/control-spec.txt

@@ -242,7 +242,8 @@ $Id$
      "SIGNAL" SP Signal CRLF
 
      Signal = "RELOAD" / "SHUTDOWN" / "DUMP" / "DEBUG" / "HALT" /
-              "HUP" / "INT" / "USR1" / "USR2" / "TERM" / "NEWNYM"
+              "HUP" / "INT" / "USR1" / "USR2" / "TERM" / "NEWNYM" /
+              "CLEARDNSCACHE"
 
   The meaning of the signals are:
 
@@ -254,8 +255,10 @@ $Id$
                    circuits. (like USR1)
       DEBUG     -- Debug: switch all open logs to loglevel debug. (like USR2)
       HALT      -- Immediate shutdown: clean up and exit now. (like TERM)
+      CLEARDNSCACHE -- Forget the client-side cached IPs for all hostnames.
       NEWNYM    -- Switch to clean circuits, so new application requests
-                   don't share any circuits with old ones.
+                   don't share any circuits with old ones.  Also clears
+                   the client-side DNS cache.
 
   The server responds with "250 OK" if the signal is recognized (or simply
   closes the socket if it was asked to close immediately), or "552

+ 2 - 0
src/or/control.c

@@ -1283,6 +1283,8 @@ handle_control_signal(control_connection_t *conn, uint32_t len,
       sig = SIGTERM;
     else if (!strcasecmp(s, "NEWNYM"))
       sig = SIGNEWNYM;
+    else if (!strcasecmp(s, "CLEARDNSCACHE"))
+      sig = SIGCLEARDNSCACHE;
     else {
       connection_printf_to_buf(conn, "552 Unrecognized signal code \"%s\"\r\n",
                                s);

+ 6 - 0
src/or/main.c

@@ -1260,6 +1260,9 @@ control_signal_act(int the_signal)
     case SIGNEWNYM:
       signal_callback(0,0,(void*)(uintptr_t)SIGNEWNYM);
       break;
+    case SIGCLEARDNSCACHE:
+      signal_callback(0,0,(void*)(uintptr_t)SIGCLEARDNSCACHE);
+      break;
     default:
       log_warn(LD_BUG, "Unrecognized signal number %d.", the_signal);
       break;
@@ -1320,6 +1323,9 @@ signal_callback(int fd, short events, void *arg)
       circuit_expire_all_dirty_circs();
       addressmap_clear_transient();
       break;
+    case SIGCLEARDNSCACHE:
+      addressmap_clear_transient();
+      break;
   }
 }
 

+ 1 - 0
src/or/or.h

@@ -147,6 +147,7 @@
 /* Controller signals start at a high number so we don't
  * conflict with system-defined signals. */
 #define SIGNEWNYM 129
+#define SIGCLEARDNSCACHE 130
 
 #if (SIZEOF_CELL_T != 0)
 /* On Irix, stdlib.h defines a cell_t type, so we need to make sure