Browse Source

Merge commit 'origin/maint-0.2.1'

Nick Mathewson 16 years ago
parent
commit
1cda6f3e75

+ 7 - 0
ChangeLog

@@ -129,6 +129,13 @@ Changes in version 0.2.1.20 - 2009-??-??
       overall failure. Bugfix on 0.1.2.6-alpha. Fixes bug 1075. Reported
       overall failure. Bugfix on 0.1.2.6-alpha. Fixes bug 1075. Reported
       by SwissTorExit.
       by SwissTorExit.
 
 
+  o Minor features:
+    - Add a "getinfo status/accepted-server-descriptor" controller
+      command, which is the recommended way for controllers to learn
+      whether our server descriptor has been successfully received by at
+      least on directory authority. Un-recommend good-server-descriptor
+      getinfo and status events until we have a better design for them.
+
 
 
 Changes in version 0.2.1.19 - 2009-07-28
 Changes in version 0.2.1.19 - 2009-07-28
   Tor 0.2.1.19 fixes a major bug with accessing and providing hidden
   Tor 0.2.1.19 fixes a major bug with accessing and providing hidden

+ 10 - 5
doc/spec/control-spec.txt

@@ -557,6 +557,7 @@
     "status/circuit-established"
     "status/circuit-established"
     "status/enough-dir-info"
     "status/enough-dir-info"
     "status/good-server-descriptor"
     "status/good-server-descriptor"
+    "status/accepted-server-descriptor"
     "status/..."
     "status/..."
       These provide the current internal Tor values for various Tor
       These provide the current internal Tor values for various Tor
       states. See Section 4.1.10 for explanations. (Only a few of the
       states. See Section 4.1.10 for explanations. (Only a few of the
@@ -1487,18 +1488,22 @@
        We successfully uploaded our server descriptor to at least one
        We successfully uploaded our server descriptor to at least one
        of the directory authorities, with no complaints.
        of the directory authorities, with no complaints.
 
 
-       {This event could affect the controller's idea of server status, but
-       the controller should not interrupt the user to tell them so.}
+       {Originally, the goal of this event was to declare "every authority
+       has accepted the descriptor, so there will be no complaints
+       about it." But since some authorities might be offline, it's
+       harder to get certainty than we had thought. As such, this event
+       is equivalent to ACCEPTED_SERVER_DESCRIPTOR below. Controllers
+       should just look at ACCEPTED_SERVER_DESCRIPTOR and should ignore
+       this event for now.}
 
 
      NAMESERVER_STATUS
      NAMESERVER_STATUS
      "NS=addr"
      "NS=addr"
      "STATUS=" "UP" / "DOWN"
      "STATUS=" "UP" / "DOWN"
      "ERR=" message
      "ERR=" message
         One of our nameservers has changed status.
         One of our nameservers has changed status.
-        // actually notice
 
 
-       {This event could affect the controller's idea of server status, but
-       the controller should not interrupt the user to tell them so.}
+        {This event could affect the controller's idea of server status, but
+        the controller should not interrupt the user to tell them so.}
 
 
      NAMESERVER_ALL_DOWN
      NAMESERVER_ALL_DOWN
         All of our nameservers have gone down.
         All of our nameservers have gone down.

+ 5 - 4
src/common/address.c

@@ -373,10 +373,11 @@ tor_addr_parse_reverse_lookup_name(tor_addr_t *result, const char *address,
       return -1; /* malformed. */
       return -1; /* malformed. */
 
 
     /* reverse the bytes */
     /* reverse the bytes */
-    inaddr.s_addr = (((inaddr.s_addr & 0x000000fful) << 24)
-                     |((inaddr.s_addr & 0x0000ff00ul) << 8)
-                     |((inaddr.s_addr & 0x00ff0000ul) >> 8)
-                     |((inaddr.s_addr & 0xff000000ul) >> 24));
+    inaddr.s_addr = (uint32_t)
+      (((inaddr.s_addr & 0x000000ff) << 24)
+       |((inaddr.s_addr & 0x0000ff00) << 8)
+       |((inaddr.s_addr & 0x00ff0000) >> 8)
+       |((inaddr.s_addr & 0xff000000) >> 24));
 
 
     if (result) {
     if (result) {
       tor_addr_from_in(result, &inaddr);
       tor_addr_from_in(result, &inaddr);

+ 2 - 2
src/common/log.c

@@ -147,8 +147,8 @@ _log_prefix(char *buf, size_t buf_len, int severity)
   t = (time_t)now.tv_sec;
   t = (time_t)now.tv_sec;
 
 
   n = strftime(buf, buf_len, "%b %d %H:%M:%S", tor_localtime_r(&t, &tm));
   n = strftime(buf, buf_len, "%b %d %H:%M:%S", tor_localtime_r(&t, &tm));
-  r = tor_snprintf(buf+n, buf_len-n, ".%.3ld [%s] ",
-                   (long)now.tv_usec / 1000, sev_to_string(severity));
+  r = tor_snprintf(buf+n, buf_len-n, ".%.3i [%s] ",
+                   (int)now.tv_usec / 1000, sev_to_string(severity));
   if (r<0)
   if (r<0)
     return buf_len-1;
     return buf_len-1;
   else
   else

+ 2 - 2
src/common/tortls.c

@@ -1442,8 +1442,8 @@ tor_tls_used_v1_handshake(tor_tls_t *tls)
  * buffer and *<b>wbuf_bytes</b> to the amount actually used. */
  * buffer and *<b>wbuf_bytes</b> to the amount actually used. */
 void
 void
 tor_tls_get_buffer_sizes(tor_tls_t *tls,
 tor_tls_get_buffer_sizes(tor_tls_t *tls,
-                         int *rbuf_capacity, int *rbuf_bytes,
-                         int *wbuf_capacity, int *wbuf_bytes)
+                         size_t *rbuf_capacity, size_t *rbuf_bytes,
+                         size_t *wbuf_capacity, size_t *wbuf_bytes)
 {
 {
   if (tls->ssl->s3->rbuf.buf)
   if (tls->ssl->s3->rbuf.buf)
     *rbuf_capacity = tls->ssl->s3->rbuf.len;
     *rbuf_capacity = tls->ssl->s3->rbuf.len;

+ 2 - 2
src/common/tortls.h

@@ -73,8 +73,8 @@ void tor_tls_get_n_raw_bytes(tor_tls_t *tls,
                              size_t *n_read, size_t *n_written);
                              size_t *n_read, size_t *n_written);
 
 
 void tor_tls_get_buffer_sizes(tor_tls_t *tls,
 void tor_tls_get_buffer_sizes(tor_tls_t *tls,
-                              int *rbuf_capacity, int *rbuf_bytes,
-                              int *wbuf_capacity, int *wbuf_bytes);
+                              size_t *rbuf_capacity, size_t *rbuf_bytes,
+                              size_t *wbuf_capacity, size_t *wbuf_bytes);
 
 
 int tor_tls_used_v1_handshake(tor_tls_t *tls);
 int tor_tls_used_v1_handshake(tor_tls_t *tls);
 
 

+ 4 - 3
src/common/util.c

@@ -1876,7 +1876,8 @@ write_chunks_to_file_impl(const char *fname, const smartlist_t *chunks,
                           int open_flags)
                           int open_flags)
 {
 {
   open_file_t *file = NULL;
   open_file_t *file = NULL;
-  int fd, result;
+  int fd;
+  ssize_t result;
   fd = start_writing_to_file(fname, open_flags, 0600, &file);
   fd = start_writing_to_file(fname, open_flags, 0600, &file);
   if (fd<0)
   if (fd<0)
     return -1;
     return -1;
@@ -1961,7 +1962,7 @@ read_file_to_str(const char *filename, int flags, struct stat *stat_out)
   int fd; /* router file */
   int fd; /* router file */
   struct stat statbuf;
   struct stat statbuf;
   char *string;
   char *string;
-  int r;
+  ssize_t r;
   int bin = flags & RFTS_BIN;
   int bin = flags & RFTS_BIN;
 
 
   tor_assert(filename);
   tor_assert(filename);
@@ -2020,7 +2021,7 @@ read_file_to_str(const char *filename, int flags, struct stat *stat_out)
        * match for size. */
        * match for size. */
       int save_errno = errno;
       int save_errno = errno;
       log_warn(LD_FS,"Could read only %d of %ld bytes of file \"%s\".",
       log_warn(LD_FS,"Could read only %d of %ld bytes of file \"%s\".",
-               r, (long)statbuf.st_size,filename);
+               (int)r, (long)statbuf.st_size,filename);
       tor_free(string);
       tor_free(string);
       close(fd);
       close(fd);
       errno = save_errno;
       errno = save_errno;

+ 1 - 1
src/or/command.c

@@ -575,7 +575,7 @@ command_process_netinfo_cell(cell_t *cell, or_connection_t *conn)
     /* Consider all the other addresses; if any matches, this connection is
     /* Consider all the other addresses; if any matches, this connection is
      * "canonical." */
      * "canonical." */
     tor_addr_t addr;
     tor_addr_t addr;
-    const char *next = decode_address_from_payload(&addr, cp, end-cp);
+    const char *next = decode_address_from_payload(&addr, cp, (int)(end-cp));
     if (next == NULL) {
     if (next == NULL) {
       log_fn(LOG_PROTOCOL_WARN,  LD_OR,
       log_fn(LOG_PROTOCOL_WARN,  LD_OR,
              "Bad address in netinfo cell; closing connection.");
              "Bad address in netinfo cell; closing connection.");

+ 3 - 2
src/or/config.c

@@ -2521,7 +2521,8 @@ is_local_addr(const tor_addr_t *addr)
      * the same /24 as last_resolved_addr will be the same as checking whether
      * the same /24 as last_resolved_addr will be the same as checking whether
      * it was on net 0, which is already done by is_internal_IP.
      * it was on net 0, which is already done by is_internal_IP.
      */
      */
-    if ((last_resolved_addr & 0xffffff00ul) == (ip & 0xffffff00ul))
+    if ((last_resolved_addr & (uint32_t)0xffffff00ul)
+        == (ip & (uint32_t)0xffffff00ul))
       return 1;
       return 1;
   }
   }
   return 0;
   return 0;
@@ -4280,7 +4281,7 @@ options_init_from_string(const char *cf,
  err:
  err:
   config_free(&options_format, newoptions);
   config_free(&options_format, newoptions);
   if (*msg) {
   if (*msg) {
-    int len = strlen(*msg)+256;
+    int len = (int)strlen(*msg)+256;
     char *newmsg = tor_malloc(len);
     char *newmsg = tor_malloc(len);
 
 
     tor_snprintf(newmsg, len, "Failed to parse/validate config: %s", *msg);
     tor_snprintf(newmsg, len, "Failed to parse/validate config: %s", *msg);

+ 6 - 2
src/or/control.c

@@ -1696,7 +1696,11 @@ getinfo_helper_events(control_connection_t *control_conn,
       *answer = tor_strdup(has_completed_circuit ? "1" : "0");
       *answer = tor_strdup(has_completed_circuit ? "1" : "0");
     } else if (!strcmp(question, "status/enough-dir-info")) {
     } else if (!strcmp(question, "status/enough-dir-info")) {
       *answer = tor_strdup(router_have_minimum_dir_info() ? "1" : "0");
       *answer = tor_strdup(router_have_minimum_dir_info() ? "1" : "0");
-    } else if (!strcmp(question, "status/good-server-descriptor")) {
+    } else if (!strcmp(question, "status/good-server-descriptor") ||
+               !strcmp(question, "status/accepted-server-descriptor")) {
+      /* They're equivalent for now, until we can figure out how to make
+       * good-server-descriptor be what we want. See comment in
+       * control-spec.txt. */
       *answer = tor_strdup(directories_have_accepted_server_descriptor()
       *answer = tor_strdup(directories_have_accepted_server_descriptor()
                            ? "1" : "0");
                            ? "1" : "0");
     } else if (!strcmp(question, "status/reachability-succeeded/or")) {
     } else if (!strcmp(question, "status/reachability-succeeded/or")) {
@@ -2495,7 +2499,7 @@ handle_control_resolve(control_connection_t *conn, uint32_t len,
   int is_reverse = 0;
   int is_reverse = 0;
   (void) len; /* body is nul-terminated; it's safe to ignore the length */
   (void) len; /* body is nul-terminated; it's safe to ignore the length */
 
 
-  if (!(conn->event_mask & (1L<<EVENT_ADDRMAP))) {
+  if (!(conn->event_mask & ((uint32_t)1L<<EVENT_ADDRMAP))) {
     log_warn(LD_CONTROL, "Controller asked us to resolve an address, but "
     log_warn(LD_CONTROL, "Controller asked us to resolve an address, but "
              "isn't listening for ADDRMAP events.  It probably won't see "
              "isn't listening for ADDRMAP events.  It probably won't see "
              "the answer.");
              "the answer.");

+ 2 - 2
src/or/directory.c

@@ -881,7 +881,7 @@ static char *
 directory_get_consensus_url(int supports_conditional_consensus)
 directory_get_consensus_url(int supports_conditional_consensus)
 {
 {
   char *url;
   char *url;
-  int len;
+  size_t len;
 
 
   if (supports_conditional_consensus) {
   if (supports_conditional_consensus) {
     char *authority_id_list;
     char *authority_id_list;
@@ -2332,7 +2332,7 @@ client_likes_consensus(networkstatus_t *v, const char *want_url)
   need_at_least = smartlist_len(want_authorities)/2+1;
   need_at_least = smartlist_len(want_authorities)/2+1;
   SMARTLIST_FOREACH(want_authorities, const char *, d, {
   SMARTLIST_FOREACH(want_authorities, const char *, d, {
     char want_digest[DIGEST_LEN];
     char want_digest[DIGEST_LEN];
-    int want_len = strlen(d)/2;
+    size_t want_len = strlen(d)/2;
     if (want_len > DIGEST_LEN)
     if (want_len > DIGEST_LEN)
       want_len = DIGEST_LEN;
       want_len = DIGEST_LEN;
 
 

+ 3 - 3
src/or/eventdns.c

@@ -2332,7 +2332,7 @@ out1:
 
 
 /* exported function */
 /* exported function */
 int
 int
-evdns_nameserver_add(unsigned long int address) {
+evdns_nameserver_add(uint32_t address) {
 	struct sockaddr_in sin;
 	struct sockaddr_in sin;
 	memset(&sin, 0, sizeof(sin));
 	memset(&sin, 0, sizeof(sin));
 	sin.sin_family = AF_INET;
 	sin.sin_family = AF_INET;
@@ -2363,13 +2363,13 @@ evdns_nameserver_ip_add(const char *ip_as_string) {
 
 
 	cp = strchr(ip_as_string, ':');
 	cp = strchr(ip_as_string, ':');
 	if (*ip_as_string == '[') {
 	if (*ip_as_string == '[') {
-		int len;
+		size_t len;
 		if (!(cp = strchr(ip_as_string, ']'))) {
 		if (!(cp = strchr(ip_as_string, ']'))) {
 			log(EVDNS_LOG_DEBUG, "Nameserver missing closing ]");
 			log(EVDNS_LOG_DEBUG, "Nameserver missing closing ]");
 			return 4;
 			return 4;
 		}
 		}
 		len = cp-(ip_as_string + 1);
 		len = cp-(ip_as_string + 1);
-		if (len > (int)sizeof(buf)-1) {
+		if (len > sizeof(buf)-1) {
 			log(EVDNS_LOG_DEBUG, "[Nameserver] does not fit in buffer.");
 			log(EVDNS_LOG_DEBUG, "[Nameserver] does not fit in buffer.");
 			return 4;
 			return 4;
 		}
 		}

+ 2 - 2
src/or/eventdns.h

@@ -112,7 +112,7 @@
  *
  *
  * API reference:
  * API reference:
  *
  *
- * int evdns_nameserver_add(unsigned long int address)
+ * int evdns_nameserver_add(uint32_t address)
  *	 Add a nameserver. The address should be an IP address in
  *	 Add a nameserver. The address should be an IP address in
  *	 network byte order. The type of address is chosen so that
  *	 network byte order. The type of address is chosen so that
  *	 it matches in_addr.s_addr.
  *	 it matches in_addr.s_addr.
@@ -258,7 +258,7 @@ typedef void (*evdns_callback_type) (int result, char type, int count, int ttl,
 int evdns_init(void);
 int evdns_init(void);
 void evdns_shutdown(int fail_requests);
 void evdns_shutdown(int fail_requests);
 const char *evdns_err_to_string(int err);
 const char *evdns_err_to_string(int err);
-int evdns_nameserver_add(unsigned long int address);
+int evdns_nameserver_add(uint32_t address);
 int evdns_count_nameservers(void);
 int evdns_count_nameservers(void);
 int evdns_clear_nameservers_and_suspend(void);
 int evdns_clear_nameservers_and_suspend(void);
 int evdns_resume(void);
 int evdns_resume(void);

+ 2 - 2
src/or/main.c

@@ -1662,7 +1662,7 @@ dumpstats(int severity)
 {
 {
   time_t now = time(NULL);
   time_t now = time(NULL);
   time_t elapsed;
   time_t elapsed;
-  int rbuf_cap, wbuf_cap, rbuf_len, wbuf_len;
+  size_t rbuf_cap, wbuf_cap, rbuf_len, wbuf_len;
 
 
   log(severity, LD_GENERAL, "Dumping stats:");
   log(severity, LD_GENERAL, "Dumping stats:");
 
 
@@ -1698,7 +1698,7 @@ dumpstats(int severity)
           log(severity, LD_GENERAL,
           log(severity, LD_GENERAL,
               "Conn %d: %d/%d bytes used on OpenSSL read buffer; "
               "Conn %d: %d/%d bytes used on OpenSSL read buffer; "
               "%d/%d bytes used on write buffer.",
               "%d/%d bytes used on write buffer.",
-              i, rbuf_len, rbuf_cap, wbuf_len, wbuf_cap);
+              i, (int)rbuf_len, (int)rbuf_cap, (int)wbuf_len, (int)wbuf_cap);
         }
         }
       }
       }
     }
     }

+ 1 - 1
src/or/rendclient.c

@@ -128,7 +128,7 @@ rend_client_send_introduction(origin_circuit_t *introcirc,
              REND_DESC_COOKIE_LEN);
              REND_DESC_COOKIE_LEN);
       v3_shift += 2+REND_DESC_COOKIE_LEN;
       v3_shift += 2+REND_DESC_COOKIE_LEN;
     }
     }
-    set_uint32(tmp+v3_shift+1, htonl(time(NULL)));
+    set_uint32(tmp+v3_shift+1, htonl((uint32_t)time(NULL)));
     v3_shift += 4;
     v3_shift += 4;
   } /* if version 2 only write version number */
   } /* if version 2 only write version number */
   else if (entry->parsed->protocols & (1<<2)) {
   else if (entry->parsed->protocols & (1<<2)) {

+ 1 - 1
src/or/rendservice.c

@@ -946,7 +946,7 @@ rend_service_introduce(origin_circuit_t *circuit, const char *request,
     /* Check timestamp. */
     /* Check timestamp. */
     memcpy((char*)&ts, buf+1+v3_shift, sizeof(uint32_t));
     memcpy((char*)&ts, buf+1+v3_shift, sizeof(uint32_t));
     v3_shift += 4;
     v3_shift += 4;
-    ts = ntohl(ts);
+    ts = ntohl((uint32_t)ts);
     if ((now - ts) < -1 * REND_REPLAY_TIME_INTERVAL / 2 ||
     if ((now - ts) < -1 * REND_REPLAY_TIME_INTERVAL / 2 ||
         (now - ts) > REND_REPLAY_TIME_INTERVAL / 2) {
         (now - ts) > REND_REPLAY_TIME_INTERVAL / 2) {
       log_warn(LD_REND, "INTRODUCE2 cell is too %s. Discarding.",
       log_warn(LD_REND, "INTRODUCE2 cell is too %s. Discarding.",

+ 3 - 2
src/or/routerparse.c

@@ -2002,8 +2002,9 @@ routerstatus_parse_entry_from_string(memarea_t *area,
     for (i=0; i < tok->n_args; ++i) {
     for (i=0; i < tok->n_args; ++i) {
       if (!strcmpstart(tok->args[i], "Bandwidth=")) {
       if (!strcmpstart(tok->args[i], "Bandwidth=")) {
         int ok;
         int ok;
-        rs->bandwidth = tor_parse_ulong(strchr(tok->args[i], '=')+1, 10,
-                                        0, UINT32_MAX, &ok, NULL);
+        rs->bandwidth = (uint32_t)tor_parse_ulong(strchr(tok->args[i], '=')+1,
+                                                  10, 0, UINT32_MAX,
+                                                  &ok, NULL);
         if (!ok) {
         if (!ok) {
           log_warn(LD_DIR, "Invalid Bandwidth %s", escaped(tok->args[i]));
           log_warn(LD_DIR, "Invalid Bandwidth %s", escaped(tok->args[i]));
           goto err;
           goto err;

+ 1 - 1
src/or/test.c

@@ -410,7 +410,7 @@ test_crypto_dh(void)
   char p2[DH_BYTES];
   char p2[DH_BYTES];
   char s1[DH_BYTES];
   char s1[DH_BYTES];
   char s2[DH_BYTES];
   char s2[DH_BYTES];
-  int s1len, s2len;
+  ssize_t s1len, s2len;
 
 
   test_eq(crypto_dh_get_bytes(dh1), DH_BYTES);
   test_eq(crypto_dh_get_bytes(dh1), DH_BYTES);
   test_eq(crypto_dh_get_bytes(dh2), DH_BYTES);
   test_eq(crypto_dh_get_bytes(dh2), DH_BYTES);

+ 2 - 2
src/tools/tor-gencert.c

@@ -70,7 +70,7 @@ show_help(void)
 static void
 static void
 crypto_log_errors(int severity, const char *doing)
 crypto_log_errors(int severity, const char *doing)
 {
 {
-  unsigned int err;
+  unsigned long err;
   const char *msg, *lib, *func;
   const char *msg, *lib, *func;
   while ((err = ERR_get_error()) != 0) {
   while ((err = ERR_get_error()) != 0) {
     msg = (const char*)ERR_reason_error_string(err);
     msg = (const char*)ERR_reason_error_string(err);
@@ -94,7 +94,7 @@ load_passphrase(void)
 {
 {
   char *cp;
   char *cp;
   char buf[1024]; /* "Ought to be enough for anybody." */
   char buf[1024]; /* "Ought to be enough for anybody." */
-  int n = read_all(passphrase_fd, buf, sizeof(buf), 0);
+  ssize_t n = read_all(passphrase_fd, buf, sizeof(buf), 0);
   if (n < 0) {
   if (n < 0) {
     log_err(LD_GENERAL, "Couldn't read from passphrase fd: %s",
     log_err(LD_GENERAL, "Couldn't read from passphrase fd: %s",
             strerror(errno));
             strerror(errno));

+ 2 - 2
src/tools/tor-resolve.c

@@ -51,7 +51,7 @@ static void usage(void) ATTR_NORETURN;
 /** Set *<b>out</b> to a newly allocated SOCKS4a resolve request with
 /** Set *<b>out</b> to a newly allocated SOCKS4a resolve request with
  * <b>username</b> and <b>hostname</b> as provided.  Return the number
  * <b>username</b> and <b>hostname</b> as provided.  Return the number
  * of bytes in the request. */
  * of bytes in the request. */
-static int
+static ssize_t
 build_socks_resolve_request(char **out,
 build_socks_resolve_request(char **out,
                             const char *username,
                             const char *username,
                             const char *hostname,
                             const char *hostname,
@@ -184,7 +184,7 @@ do_resolve(const char *hostname, uint32_t sockshost, uint16_t socksport,
   int s;
   int s;
   struct sockaddr_in socksaddr;
   struct sockaddr_in socksaddr;
   char *req = NULL;
   char *req = NULL;
-  int len = 0;
+  ssize_t len = 0;
 
 
   tor_assert(hostname);
   tor_assert(hostname);
   tor_assert(result_addr);
   tor_assert(result_addr);