Commit a2517b4f authored by Roger Dingledine's avatar Roger Dingledine
Browse files

checking only 0.0.7 and 0.0.8 didn't work, because some dirservers

files have really old descriptors for the authdirservers, so we're
asking them in the new format because they're too old.

now we actually compare the version to a cutoff version, and act
appropriately.

also take this chance to use only >=0.0.8 servers for dns resolves,
because of the recent bugs. we'll bump to >=0.0.9pre1 once there are
some servers running that.


svn:r2380
parent a64d0933
Loading
Loading
Loading
Loading
+4 −4
Changes for src/or/circuituse.c: 4 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -76,10 +76,10 @@ static int circuit_is_acceptable(circuit_t *circ,

    if (conn->socks_request &&
        conn->socks_request->command == SOCKS_COMMAND_RESOLVE) {
      /* 0.0.7 servers and earlier don't support DNS resolution.  There are no
       * ORs running code before 0.0.7, so we only worry about 0.0.7.  Once all
       * servers are running 0.0.8, remove this check. */
      if (!strcmpstart(exitrouter->platform, "Tor 0.0.7"))
      /* 0.0.7 servers and earlier don't support DNS resolution.  0.0.8 servers
       * have buggy resolve support. Once there are more 0.0.9 servers, change
       * this to 0.0.9pre1. XXX */
      if (!tor_version_as_new_as(exitrouter->platform, "0.0.8"))
        return 0;
    } else if(purpose == CIRCUIT_PURPOSE_C_GENERAL) {
      if(!connection_ap_can_use_exit(conn, exitrouter)) {
+4 −4
Changes for src/or/connection_edge.c: 4 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -954,10 +954,10 @@ int connection_ap_can_use_exit(connection_t *conn, routerinfo_t *exit)
         exit->nickname, conn->socks_request->address,
         conn->socks_request->port);
  if (conn->socks_request->command == SOCKS_COMMAND_RESOLVE) {
    /* 0.0.7 servers and earlier don't support DNS resolution.  There are no
     * ORs running code before 0.0.7, so we only worry about 0.0.7.  Once all
     * servers are running 0.0.8, remove this check. XXX */
    return strcmpstart(exit->platform, "Tor 0.0.7") ? 1 : 0;
    /* 0.0.7 servers and earlier don't support DNS resolution.  0.0.8 servers
     * have buggy resolve support. Once there are more 0.0.9 servers, change
     * this to 0.0.9pre1. XXX */
    return tor_version_as_new_as(exit->platform, "0.0.8");
  }
  addr = client_dns_lookup_entry(conn->socks_request->address);
  if(router_compare_addr_to_exit_policy(addr,
+1 −1
Changes for src/or/connection_or.c: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -218,7 +218,7 @@ int connection_tls_start_handshake(connection_t *conn, int receiving) {
    him = router_get_by_digest(conn->identity_digest);
    me = router_get_my_routerinfo();

    if(him && !strcmpstart(him->platform, "Tor 0.0.7") &&
    if(him && !tor_version_as_new_as(him->platform, "0.0.8pre1") &&
       (!me || !me->is_verified)) {
      log_fn(LOG_INFO,"He's running 0.0.7, and I'm unverified. Acting like OP.");
      use_no_cert = 1;
+7 −5
Changes for src/or/directory.c: 7 added lines, 5 removed lines.
Original line number Diff line number Diff line
@@ -214,20 +214,22 @@ static void directory_send_command(connection_t *conn, int purpose,
  char fetchrunninglist[] = "GET /tor/running-routers HTTP/1.0\r\n\r\n";
  char tmp[8192];
  routerinfo_t *router;
  int use_newer = 0;

  tor_assert(conn && conn->type == CONN_TYPE_DIR);

  router = router_get_by_digest(conn->identity_digest);
  tor_assert(router); /* the func that calls us found it, so we should too */

  use_newer = tor_version_as_new_as(router->platform, "0.0.9pre1");

  switch(purpose) {
    case DIR_PURPOSE_FETCH_DIR:
      tor_assert(payload == NULL);
      if (!strcmpstart(router->platform, "Tor 0.0.7") ||
          !strcmpstart(router->platform, "Tor 0.0.8"))
        connection_write_to_buf(fetchwholedir, strlen(fetchwholedir), conn);
      else
      if(use_newer)
        connection_write_to_buf(fetchwholedir_z, strlen(fetchwholedir_z), conn);
      else
        connection_write_to_buf(fetchwholedir, strlen(fetchwholedir), conn);
      break;
    case DIR_PURPOSE_FETCH_RUNNING_LIST:
      tor_assert(payload == NULL);
@@ -236,7 +238,7 @@ static void directory_send_command(connection_t *conn, int purpose,
    case DIR_PURPOSE_UPLOAD_DIR:
      tor_assert(payload);
      snprintf(tmp, sizeof(tmp), "POST %s/ HTTP/1.0\r\nContent-Length: %d\r\n\r\n",
               strcmpstart(router->platform, "Tor 0.0.8") ? "/tor" : "",
               use_newer ? "/tor" : "",
               payload_len);
      connection_write_to_buf(tmp, strlen(tmp), conn);
      connection_write_to_buf(payload, payload_len, conn);
+1 −1
Changes for src/or/or.h: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -1461,8 +1461,8 @@ struct exit_policy_t *router_parse_exit_policy_from_string(const char *s);
int check_software_version_against_directory(const char *directory,
                                             int ignoreversion);
int tor_version_parse(const char *s, tor_version_t *out);
int tor_version_as_new_as(const char *platform, const char *cutoff);
int tor_version_compare(tor_version_t *a, tor_version_t *b);
int tor_version_compare_to_mine(const char *s);

#endif

Loading