Commit 74e6a47a authored by Roger Dingledine's avatar Roger Dingledine
Browse files

stop setting, or using, router->address

resolves ticket 5528.
parent 002c860c
Loading
Loading
Loading
Loading

changes/ticket5528

0 → 100644
+4 −0
Original line number Diff line number Diff line
  o Code simplifications and refactoring:
    - Get rid of router->address, since in all cases it was just the
      string representation of router->addr. Resolves ticket 5528.
+0 −2
Original line number Diff line number Diff line
@@ -1876,8 +1876,6 @@ rewrite_node_address_for_bridge(const bridge_info_t *bridge, node_t *node)
    } else {
      if (tor_addr_family(&bridge->addr) == AF_INET) {
        ri->addr = tor_addr_to_ipv4h(&bridge->addr);
        tor_free(ri->address);
        ri->address = tor_dup_ip(ri->addr);
        ri->or_port = bridge->port;
        log_info(LD_DIR,
                 "Adjusted bridge routerinfo for '%s' to match configured "
+0 −1
Original line number Diff line number Diff line
@@ -1925,7 +1925,6 @@ typedef int16_t country_t;
/** Information about another onion router in the network. */
typedef struct {
  signed_descriptor_t cache_info;
  char *address; /**< Location of OR: either a hostname or an IP address. */
  char *nickname; /**< Human-readable OR name. */

  uint32_t addr; /**< IPv4 address of OR, in host order. */
+5 −2
Original line number Diff line number Diff line
@@ -1759,7 +1759,6 @@ router_rebuild_descriptor(int force)

  ri = tor_malloc_zero(sizeof(routerinfo_t));
  ri->cache_info.routerlist_index = -1;
  ri->address = tor_dup_ip(addr);
  ri->nickname = tor_strdup(options->Nickname);
  ri->addr = addr;
  ri->or_port = router_get_advertised_or_port(options);
@@ -2218,6 +2217,7 @@ int
router_dump_router_to_string(char *s, size_t maxlen, routerinfo_t *router,
                             crypto_pk_t *ident_key)
{
  char *address;
  char *onion_pkey; /* Onion key, PEM-encoded. */
  char *identity_pkey; /* Identity key, PEM-encoded. */
  char digest[DIGEST_LEN];
@@ -2292,6 +2292,8 @@ router_dump_router_to_string(char *s, size_t maxlen, routerinfo_t *router,
    }
  }

  address = tor_dup_ip(router->addr);

  /* Generate the easy portion of the router descriptor. */
  result = tor_snprintf(s, maxlen,
                    "router %s %s %d 0 %d\n"
@@ -2307,7 +2309,7 @@ router_dump_router_to_string(char *s, size_t maxlen, routerinfo_t *router,
                    "signing-key\n%s"
                    "%s%s%s%s",
    router->nickname,
    router->address,
    address,
    router->or_port,
    decide_to_advertise_dirport(options, router->dir_port),
    extra_or_address ? extra_or_address : "",
@@ -2328,6 +2330,7 @@ router_dump_router_to_string(char *s, size_t maxlen, routerinfo_t *router,
    options->HidServDirectoryV2 ? "hidden-service-dir\n" : "",
    options->AllowSingleHopExits ? "allow-single-hop-exits\n" : "");

  tor_free(address);
  tor_free(family_line);
  tor_free(onion_pkey);
  tor_free(identity_pkey);
+1 −2
Original line number Diff line number Diff line
@@ -2538,7 +2538,6 @@ routerinfo_free(routerinfo_t *router)
    return;

  tor_free(router->cache_info.signed_descriptor_body);
  tor_free(router->address);
  tor_free(router->nickname);
  tor_free(router->platform);
  tor_free(router->contact_info);
@@ -4743,7 +4742,7 @@ router_differences_are_cosmetic(const routerinfo_t *r1, const routerinfo_t *r2)
  }

  /* If any key fields differ, they're different. */
  if (strcasecmp(r1->address, r2->address) ||
  if (r1->addr != r2->addr ||
      strcasecmp(r1->nickname, r2->nickname) ||
      r1->or_port != r2->or_port ||
      !tor_addr_eq(&r1->ipv6_addr, &r2->ipv6_addr) ||
Loading