[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] r12310: As an authority, send back an X-Descriptor-Not-New header wh (in tor/trunk: . doc src/or)



Author: nickm
Date: 2007-11-01 01:01:24 -0400 (Thu, 01 Nov 2007)
New Revision: 12310

Modified:
   tor/trunk/
   tor/trunk/ChangeLog
   tor/trunk/doc/TODO
   tor/trunk/src/or/directory.c
Log:
 r16326@catbus:  nickm | 2007-11-01 00:56:45 -0400
 As an authority, send back an X-Descriptor-Not-New header when we accept but do not store a descriptor.  Partial implementation of fix for bug 535.



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /tor/trunk [r16326] on 8246c3cf-6607-4228-993b-4d95d33730f1

Modified: tor/trunk/ChangeLog
===================================================================
--- tor/trunk/ChangeLog	2007-11-01 04:43:02 UTC (rev 12309)
+++ tor/trunk/ChangeLog	2007-11-01 05:01:24 UTC (rev 12310)
@@ -41,6 +41,9 @@
       claims about the authority's IP address.
     - New --quiet command-line option to suppress the default console log.
       Good in combination with --hash-password.
+    - Authorities send back an X-Descriptor-Not-New header in response to
+      an accepted-but-discarded descriptor upload.  Partially implements
+      fix for bug 535.
 
   o Minor features (controller):
     - When reporting clock skew, and we only have a lower bound on the amount

Modified: tor/trunk/doc/TODO
===================================================================
--- tor/trunk/doc/TODO	2007-11-01 04:43:02 UTC (rev 12309)
+++ tor/trunk/doc/TODO	2007-11-01 05:01:24 UTC (rev 12310)
@@ -57,7 +57,8 @@
           and send netinfo and be "open".
         o On netinfo, warn if there's skew from a server.
         - Learn our outgoing IP address from netinfo cells?
-        - Earliest stages of 110 (infinite-length) in v2 protocol.
+        - Earliest stages of 110 (infinite-length) in v2 protocol:
+          add support for RELAY_EARLY.
       - TLS only
         - Need to get a finished TLS normalization proposal
         - Revised authentication.
@@ -207,7 +208,7 @@
     - Limit to 2 dir, 2 OR, N SOCKS connections per IP.
       - Or maybe close connections from same IP when we get a lot from one.
       - Or maybe block IPs that connect too many times at once.
-    - add an AuthDirBadexit torrc option if we decide we want one.
+    D add an AuthDirBadexit torrc option if we decide we want one.
 
   - Testing
 N   - Hack up a client that gives out weird/no certificates, so we can

Modified: tor/trunk/src/or/directory.c
===================================================================
--- tor/trunk/src/or/directory.c	2007-11-01 04:43:02 UTC (rev 12309)
+++ tor/trunk/src/or/directory.c	2007-11-01 05:01:24 UTC (rev 12310)
@@ -1631,6 +1631,17 @@
       case 200: {
           trusted_dir_server_t *ds =
             router_get_trusteddirserver_by_digest(conn->identity_digest);
+          char *rejected_hdr = http_get_header(headers,
+                                               "X-Descriptor-Not-New: ");
+          int rejected = 0;
+          if (rejected_hdr) {
+            if (!strcmp(rejected, "Yes")) {
+              /* XXXX020 use this information; be sure to upload next one
+               * sooner. */
+              rejected = 1;
+            }
+            tor_free(rejected_hdr);
+          }
           log_info(LD_GENERAL,"eof (status 200) after uploading server "
                    "descriptor: finished.");
           control_event_server_status(
@@ -1898,6 +1909,7 @@
 static void
 write_http_response_header_impl(dir_connection_t *conn, ssize_t length,
                            const char *type, const char *encoding,
+                           const cahr *extra_headers,
                            int cache_lifetime)
 {
   char date[RFC1123_TIME_LEN+1];
@@ -1911,9 +1923,13 @@
   format_rfc1123_time(date, now);
   cp = tmp;
   tor_snprintf(cp, sizeof(tmp),
-               "HTTP/1.0 200 OK\r\nDate: %s\r\nContent-Type: %s\r\n",
-               date, type);
+               "HTTP/1.0 200 OK\r\nDate: %s\r\n",
+               date);
   cp += strlen(tmp);
+  if (type) {
+    tor_snprintf(cp, sizeof(tmp)-(cp-tmp), "Content-Type: %s\r\n", type);
+    cp += strlen(cp);
+  }
   if (!is_internal_IP(conn->_base.addr, 0)) {
     /* Don't report the source address for a localhost/private connection. */
     tor_snprintf(cp, sizeof(tmp)-(cp-tmp),
@@ -1938,12 +1954,14 @@
     tor_snprintf(cp, sizeof(tmp)-(cp-tmp),
                  "Expires: %s\r\n", expbuf);
     cp += strlen(cp);
-  } else {
+  } else if (cache_lifetime == 0) {
     /* We could say 'Cache-control: no-cache' here if we start doing
      * http/1.1 */
     strlcpy(cp, "Pragma: no-cache\r\n", sizeof(tmp)-(cp-tmp));
     cp += strlen(cp);
   }
+  if (extra_headers)
+    strlcpy(cp, extra_headers, sizeof(tmp)-(cp-tmp));
   if (sizeof(tmp)-(cp-tmp) > 3)
     memcpy(cp, "\r\n", 3);
   else
@@ -1960,6 +1978,7 @@
   write_http_response_header_impl(conn, length,
                           deflated?"application/octet-stream":"text/plain",
                           deflated?"deflate":"identity",
+                             NULL,
                              cache_lifetime);
 }
 
@@ -2527,8 +2546,8 @@
     switch (rend_cache_lookup_desc(query, 0, &descp, &desc_len)) {
       case 1: /* valid */
         write_http_response_header_impl(conn, desc_len,
-                                   "application/octet-stream",
-                                   NULL, 0);
+                                        "application/octet-stream",
+                                        NULL, NULL, 0);
         note_request("/tor/rendezvous?/", desc_len);
         /* need to send descp separately, because it may include nuls */
         connection_write_to_buf(descp, desc_len, TO_CONN(conn));
@@ -2685,6 +2704,9 @@
         write_http_status_line(conn, 400, msg);
         break;
       case 0: /* accepted but discarded */
+        write_http_response_header(conn, -1, NULL, NULL,
+                                   "X-Descriptor-Not-New: Yes\r\n", -1);
+        break;
       case 2: /* accepted */
         write_http_status_line(conn, 200, msg);
         break;