Explorar el Código

r9005@Kushana: nickm | 2006-09-29 10:37:55 -0400
Implement DESCCHANGED event to tell controller when our router descriptor changes.


svn:r8533

Nick Mathewson hace 18 años
padre
commit
0335bd51d3
Se han modificado 5 ficheros con 21 adiciones y 3 borrados
  1. 2 0
      ChangeLog
  2. 4 2
      doc/TODO
  3. 13 1
      src/or/control.c
  4. 1 0
      src/or/or.h
  5. 1 0
      src/or/router.c

+ 2 - 0
ChangeLog

@@ -40,6 +40,8 @@ Changes in version 0.1.2.2-alpha - 2006-??-??
       any router can call itself Unnamed; directory servers will never
       allocate Unnamed to any particular router; clients won't believe that
       any router is the canonical Unnamed.
+    - New controller event to alert the controller when our server descriptor
+      has changed.
 
   o Security Fixes, minor:
     - If a client asked for a server by name, and we didn't have a

+ 4 - 2
doc/TODO

@@ -85,8 +85,8 @@ N - Simplify authority operation
         registered and can't be looked up by nickname.]
 d     - Tolerate clock skew on bridge relays.
 d     - A way to examine and twiddle router flags from controller.
-      - A way to export server descriptors to controllers
-N         - Event / getinfo for "when did routerdesc last change".
+      o A way to export server descriptors to controllers
+          o Event for "when did routerdesc last change".
 d     - a way to pick entries based wholly on extend_info equivalent;
         a way to export extend_info equivalent.
 R     - option to dl directory info via tor
@@ -410,6 +410,8 @@ Future version:
     - Specify; implement.
   - let each hidden service (or other thing) specify its own
     OutboundBindAddress?
+  - Stop using tor_socketpair to make connection bridges: do an
+    implementation that uses buffers only.
 
 Blue-sky:
   - Patch privoxy and socks protocol to pass strings to the browser.

+ 13 - 1
src/or/control.c

@@ -77,7 +77,8 @@ const char control_c_id[] =
 #define LAST_V0_EVENT         0x000B
 #define EVENT_ADDRMAP         0x000C
 #define EVENT_AUTHDIR_NEWDESCS 0x000D
-#define _EVENT_MAX            0x000D
+#define EVENT_DESCCHANGED     0x000E
+#define _EVENT_MAX            0x000E
 
 /** Array mapping from message type codes to human-readable message
  * type names. Used for compatibility with version 0 of the control
@@ -952,6 +953,8 @@ handle_control_setevents(control_connection_t *conn, uint32_t len,
           event_code = EVENT_ADDRMAP;
         else if (!strcasecmp(ev, "AUTHDIR_NEWDESCS"))
           event_code = EVENT_AUTHDIR_NEWDESCS;
+        else if (!strcasecmp(ev, "DESCCHANGED"))
+          event_code = EVENT_DESCCHANGED;
         else {
           connection_printf_to_buf(conn, "552 Unrecognized event \"%s\"\r\n",
                                    ev);
@@ -2982,6 +2985,15 @@ control_event_or_authdir_new_descriptor(const char *action,
   return 0;
 }
 
+/** Our own router descriptor has changed; tell any controllers that care.
+ */
+int
+control_event_my_descriptor_changed(void)
+{
+  send_control1_event(EVENT_DESCCHANGED, "650 DESCCHANGED\r\n");
+  return 0;
+}
+
 /** Choose a random authentication cookie and write it to disk.
  * Anybody who can read the cookie from disk will be considered
  * authorized to use the control connection. */

+ 1 - 0
src/or/or.h

@@ -2063,6 +2063,7 @@ int control_event_address_mapped(const char *from, const char *to,
 int control_event_or_authdir_new_descriptor(const char *action,
                                             const char *descriptor,
                                             const char *msg);
+int control_event_my_descriptor_changed(void);
 
 int init_cookie_authentication(int enabled);
 int decode_hashed_password(char *buf, const char *hashed);

+ 1 - 0
src/or/router.c

@@ -903,6 +903,7 @@ router_rebuild_descriptor(int force)
 
   desc_clean_since = time(NULL);
   desc_needs_upload = 1;
+  control_event_my_descriptor_changed();
   return 0;
 }