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

[tor-commits] [tor/master] Merge remote-tracking branch 'linus/bug5053-bug5055'



commit 626a8b60d7752f38e6587bed9b614c6d039dd9f7
Merge: e5ca504 ffddd4d
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date:   Sun Nov 4 21:44:31 2012 -0500

    Merge remote-tracking branch 'linus/bug5053-bug5055'
    
    Conflicts:
    	src/or/geoip.c

 changes/5053        |    4 +
 changes/5055        |    9 +
 doc/tor.1.txt       |    5 +-
 src/config/geoip6   |11638 +++++++++++++++++++++++++++++++++++++++++++++++++++
 src/or/config.c     |   69 +-
 src/or/geoip.c      |  465 ++-
 src/or/geoip.h      |   14 +-
 src/or/nodelist.c   |   11 +-
 src/or/or.h         |    3 +-
 src/or/policies.c   |    6 +-
 src/or/router.c     |    9 +-
 src/or/routerlist.c |    2 +-
 src/or/routerset.c  |    6 +-
 src/test/test.c     |  113 +-
 14 files changed, 12146 insertions(+), 208 deletions(-)

diff --cc src/or/geoip.c
index bb3e011,9aba3c9..3036ee2
--- a/src/or/geoip.c
+++ b/src/or/geoip.c
@@@ -231,15 -338,20 +338,20 @@@ geoip_load_file(sa_family_t family, con
    /*XXXX abort and return -1 if no entries/illformed?*/
    fclose(f);
  
-   smartlist_sort(geoip_entries, geoip_compare_entries_);
- 
-   /* Okay, now we need to maybe change our mind about what is in which
-    * country. */
-   refresh_all_country_info();
- 
-   /* Remember file digest so that we can include it in our extra-info
-    * descriptors. */
-   crypto_digest_get_digest(geoip_digest_env, geoip_digest, DIGEST_LEN);
+   /* Sort list and remember file digests so that we can include it in
+    * our extra-info descriptors. */
+   if (family == AF_INET) {
+     smartlist_sort(geoip_ipv4_entries, geoip_ipv4_compare_entries_);
+     /* Okay, now we need to maybe change our mind about what is in
+      * which country. We do this for IPv4 only since that's what we
+      * store in node->country. */
+     refresh_all_country_info();
+     crypto_digest_get_digest(geoip_digest_env, geoip_digest, DIGEST_LEN);
 -  }
 -  else {                        /* AF_INET6 */
++  } else {
++    /* AF_INET6 */
+     smartlist_sort(geoip_ipv6_entries, geoip_ipv6_compare_entries_);
+     crypto_digest_get_digest(geoip_digest_env, geoip6_digest, DIGEST_LEN);
+   }
    crypto_digest_free(geoip_digest_env);
  
    return 0;
@@@ -559,10 -701,10 +701,10 @@@ typedef struct c_hist_t 
  } c_hist_t;
  
  /** Sorting helper: return -1, 1, or 0 based on comparison of two
-  * geoip_entry_t.  Sort in descending order of total, and then by country
+  * geoip_ipv4_entry_t.  Sort in descending order of total, and then by country
   * code. */
  static int
 -_c_hist_compare(const void **_a, const void **_b)
 +c_hist_compare_(const void **_a, const void **_b)
  {
    const c_hist_t *a = *_a, *b = *_b;
    if (a->total > b->total)
@@@ -868,17 -1042,14 +1042,14 @@@ geoip_get_client_history(geoip_client_a
    }
    /* Sort entries. Note that we must do this _AFTER_ rounding, or else
     * the sort order could leak info. */
 -  smartlist_sort(entries, _c_hist_compare);
 +  smartlist_sort(entries, c_hist_compare_);
  
-   /* Build the result. */
-   chunks = smartlist_new();
-   SMARTLIST_FOREACH(entries, c_hist_t *, ch, {
-       smartlist_add_asprintf(chunks, "%s=%u", ch->country, ch->total);
-   });
-   result = smartlist_join_strings(chunks, ",", 0, NULL);
-  done:
-   tor_free(counts);
-   if (chunks) {
+   if (country_str) {
+     smartlist_t *chunks = smartlist_new();
+     SMARTLIST_FOREACH(entries, c_hist_t *, ch, {
+         smartlist_add_asprintf(chunks, "%s=%u", ch->country, ch->total);
+       });
+     *country_str = smartlist_join_strings(chunks, ",", 0, NULL);
      SMARTLIST_FOREACH(chunks, char *, c, tor_free(c));
      smartlist_free(chunks);
    }
diff --cc src/or/geoip.h
index bda5fe2,5a17bc2..2272486
--- a/src/or/geoip.h
+++ b/src/or/geoip.h
@@@ -9,15 -9,16 +9,16 @@@
   * \brief Header file for geoip.c.
   **/
  
 -#ifndef _TOR_GEOIP_H
 -#define _TOR_GEOIP_H
 +#ifndef TOR_GEOIP_H
 +#define TOR_GEOIP_H
  
  #ifdef GEOIP_PRIVATE
- int geoip_parse_entry(const char *line);
+ int geoip_parse_entry(const char *line, sa_family_t family);
+ int geoip_get_country_by_ipv4(uint32_t ipaddr);
+ int geoip_get_country_by_ipv6(const struct in6_addr *addr);
  #endif
  int should_record_bridge_info(const or_options_t *options);
- int geoip_load_file(const char *filename, const or_options_t *options);
- int geoip_get_country_by_ip(uint32_t ipaddr);
+ int geoip_load_file(sa_family_t family, const char *filename);
  int geoip_get_country_by_addr(const tor_addr_t *addr);
  int geoip_get_n_countries(void);
  const char *geoip_get_country_name(country_t num);
diff --cc src/or/routerlist.c
index 8c83149,9537331..1cefef9
--- a/src/or/routerlist.c
+++ b/src/or/routerlist.c
@@@ -4788,10 -4787,10 +4788,10 @@@ compare_routerinfo_by_id_digest_(const 
  void
  routers_sort_by_identity(smartlist_t *routers)
  {
 -  smartlist_sort(routers, _compare_routerinfo_by_id_digest);
 +  smartlist_sort(routers, compare_routerinfo_by_id_digest_);
  }
  
- /** Called when we change a node set, or when we reload the geoip list:
+ /** Called when we change a node set, or when we reload the geoip IPv4 list:
   * recompute all country info in all configuration node sets and in the
   * routerlist. */
  void



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits