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

[tor-commits] [tor/master] Merge remote-tracking branch 'public/prop227_v2'



commit fac8d40886a03d442ed9f8c18df5ed017b1e6dd0
Merge: d1e52d9 b4a8fd8
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date:   Fri Jan 30 07:36:55 2015 -0500

    Merge remote-tracking branch 'public/prop227_v2'
    
    Conflicts:
    	src/test/test_dir.c

 changes/prop227        |    5 ++
 doc/tor.1.txt          |    6 ++
 src/common/container.c |   25 ++++++--
 src/common/container.h |    8 ++-
 src/or/config.c        |    9 +++
 src/or/control.c       |    2 +
 src/or/dirserv.c       |   86 ++++++++++++++++++++++++++++
 src/or/dirserv.h       |    2 +
 src/or/dirvote.c       |  100 +++++++++++++++++++++++++++++++-
 src/or/dirvote.h       |    6 +-
 src/or/networkstatus.c |   31 ++++++++++
 src/or/or.h            |    4 ++
 src/or/routerparse.c   |   12 ++++
 src/test/test_dir.c    |  147 ++++++++++++++++++++++++++++++++++++++++++++++++
 14 files changed, 435 insertions(+), 8 deletions(-)

diff --cc src/test/test_dir.c
index 991e613,efc3ec7..84e80ea
--- a/src/test/test_dir.c
+++ b/src/test/test_dir.c
@@@ -2931,29 -2930,151 +2931,175 @@@ test_dir_http_handling(void *args
  }
  
  static void
 +test_dir_purpose_needs_anonymity(void *arg)
 +{
 +  (void)arg;
 +  tt_int_op(1, ==, purpose_needs_anonymity(0, ROUTER_PURPOSE_BRIDGE));
 +  tt_int_op(1, ==, purpose_needs_anonymity(0, ROUTER_PURPOSE_GENERAL));
 +  tt_int_op(0, ==, purpose_needs_anonymity(DIR_PURPOSE_FETCH_MICRODESC,
 +                                            ROUTER_PURPOSE_GENERAL));
 + done: ;
 +}
 +
 +static void
 +test_dir_fetch_type(void *arg)
 +{
 +  (void)arg;
 +  tt_assert(dir_fetch_type(DIR_PURPOSE_FETCH_MICRODESC, ROUTER_PURPOSE_GENERAL,
 +                           NULL) == MICRODESC_DIRINFO);
 +  tt_assert(dir_fetch_type(DIR_PURPOSE_FETCH_SERVERDESC, ROUTER_PURPOSE_BRIDGE,
 +                           NULL) == BRIDGE_DIRINFO);
 +  tt_assert(dir_fetch_type(DIR_PURPOSE_FETCH_CONSENSUS, ROUTER_PURPOSE_GENERAL,
 +                           "microdesc") == (V3_DIRINFO | MICRODESC_DIRINFO));
 + done: ;
 +}
 +
++static void
+ test_dir_packages(void *arg)
+ {
+   smartlist_t *votes = smartlist_new();
+   char *res = NULL;
+   (void)arg;
+ 
+ #define BAD(s) \
+   tt_int_op(0, ==, validate_recommended_package_line(s));
+ #define GOOD(s) \
+   tt_int_op(1, ==, validate_recommended_package_line(s));
+   GOOD("tor 0.2.6.3-alpha "
+        "http://torproject.example.com/dist/tor-0.2.6.3-alpha.tar.gz "
+        "sha256=sssdlkfjdsklfjdskfljasdklfj");
+   GOOD("tor 0.2.6.3-alpha "
+        "http://torproject.example.com/dist/tor-0.2.6.3-alpha.tar.gz "
+        "sha256=sssdlkfjdsklfjdskfljasdklfj blake2b=fred");
+   BAD("tor 0.2.6.3-alpha "
+        "http://torproject.example.com/dist/tor-0.2.6.3-alpha.tar.gz "
+        "sha256=sssdlkfjdsklfjdskfljasdklfj=");
+   BAD("tor 0.2.6.3-alpha "
+        "http://torproject.example.com/dist/tor-0.2.6.3-alpha.tar.gz "
+        "sha256=sssdlkfjdsklfjdskfljasdklfj blake2b");
+   BAD("tor 0.2.6.3-alpha "
+        "http://torproject.example.com/dist/tor-0.2.6.3-alpha.tar.gz ");
+   BAD("tor 0.2.6.3-alpha "
+        "http://torproject.example.com/dist/tor-0.2.6.3-alpha.tar.gz";);
+   BAD("tor 0.2.6.3-alpha ");
+   BAD("tor 0.2.6.3-alpha");
+   BAD("tor ");
+   BAD("tor");
+   BAD("");
+   BAD("=foobar sha256="
+       "3c179f46ca77069a6a0bac70212a9b3b838b2f66129cb52d568837fc79d8fcc7");
+   BAD("= = sha256="
+       "3c179f46ca77069a6a0bac70212a9b3b838b2f66129cb52d568837fc79d8fcc7");
+ 
+   BAD("sha512= sha256="
+       "3c179f46ca77069a6a0bac70212a9b3b838b2f66129cb52d568837fc79d8fcc7");
+ 
+   votes = smartlist_new();
+   smartlist_add(votes, tor_malloc_zero(sizeof(networkstatus_t)));
+   smartlist_add(votes, tor_malloc_zero(sizeof(networkstatus_t)));
+   smartlist_add(votes, tor_malloc_zero(sizeof(networkstatus_t)));
+   smartlist_add(votes, tor_malloc_zero(sizeof(networkstatus_t)));
+   smartlist_add(votes, tor_malloc_zero(sizeof(networkstatus_t)));
+   smartlist_add(votes, tor_malloc_zero(sizeof(networkstatus_t)));
+   SMARTLIST_FOREACH(votes, networkstatus_t *, ns,
+                     ns->package_lines = smartlist_new());
+ 
+ #define ADD(i, s)                                                       \
+   smartlist_add(((networkstatus_t*)smartlist_get(votes, (i)))->package_lines, \
+                 (void*)(s));
+ 
+   /* Only one vote for this one. */
+   ADD(4, "cisco 99z http://foobar.example.com/ sha256=blahblah");
+ 
+   /* Only two matching entries for this one, but 3 voters */
+   ADD(1, "mystic 99y http://barfoo.example.com/ sha256=blahblah");
+   ADD(3, "mystic 99y http://foobar.example.com/ sha256=blahblah");
+   ADD(4, "mystic 99y http://foobar.example.com/ sha256=blahblah");
+ 
+   /* Only two matching entries for this one, but at least 4 voters */
+   ADD(1, "mystic 99p http://barfoo.example.com/ sha256=ggggggg");
+   ADD(3, "mystic 99p http://foobar.example.com/ sha256=blahblah");
+   ADD(4, "mystic 99p http://foobar.example.com/ sha256=blahblah");
+   ADD(5, "mystic 99p http://foobar.example.com/ sha256=ggggggg");
+ 
+   /* This one has only invalid votes. */
+   ADD(0, "haffenreffer 1.2 http://foobar.example.com/ sha256");
+   ADD(1, "haffenreffer 1.2 http://foobar.example.com/ ");
+   ADD(2, "haffenreffer 1.2 ");
+   ADD(3, "haffenreffer ");
+   ADD(4, "haffenreffer");
+ 
+   /* Three matching votes for this; it should actually go in! */
+   ADD(2, "element 0.66.1 http://quux.example.com/ sha256=abcdef");
+   ADD(3, "element 0.66.1 http://quux.example.com/ sha256=abcdef");
+   ADD(4, "element 0.66.1 http://quux.example.com/ sha256=abcdef");
+   ADD(1, "element 0.66.1 http://quum.example.com/ sha256=abcdef");
+   ADD(0, "element 0.66.1 http://quux.example.com/ sha256=abcde");
+ 
+   /* Three votes for A, three votes for B */
+   ADD(0, "clownshoes 22alpha1 http://quumble.example.com/ blake2=foob");
+   ADD(1, "clownshoes 22alpha1 http://quumble.example.com/ blake2=foob");
+   ADD(2, "clownshoes 22alpha1 http://quumble.example.com/ blake2=foob");
+   ADD(3, "clownshoes 22alpha1 http://quumble.example.com/ blake2=fooz");
+   ADD(4, "clownshoes 22alpha1 http://quumble.example.com/ blake2=fooz");
+   ADD(5, "clownshoes 22alpha1 http://quumble.example.com/ blake2=fooz");
+ 
+   /* Three votes for A, two votes for B */
+   ADD(1, "clownshoes 22alpha3 http://quumble.example.com/ blake2=foob");
+   ADD(2, "clownshoes 22alpha3 http://quumble.example.com/ blake2=foob");
+   ADD(3, "clownshoes 22alpha3 http://quumble.example.com/ blake2=fooz");
+   ADD(4, "clownshoes 22alpha3 http://quumble.example.com/ blake2=fooz");
+   ADD(5, "clownshoes 22alpha3 http://quumble.example.com/ blake2=fooz");
+ 
+   /* Four votes for A, two for B. */
+   ADD(0, "clownshoes 22alpha4 http://quumble.example.com/ blake2=foob");
+   ADD(1, "clownshoes 22alpha4 http://quumble.example.com/ blake2=foob");
+   ADD(2, "clownshoes 22alpha4 http://quumble.example.cam/ blake2=fooa");
+   ADD(3, "clownshoes 22alpha4 http://quumble.example.cam/ blake2=fooa");
+   ADD(4, "clownshoes 22alpha4 http://quumble.example.cam/ blake2=fooa");
+   ADD(5, "clownshoes 22alpha4 http://quumble.example.cam/ blake2=fooa");
+ 
+   /* Five votes for A ... all from the same guy.  Three for B. */
+   ADD(0, "cbc 99.1.11.1.1 http://example.com/cbc/ cubehash=ahooy sha512=m");
+   ADD(1, "cbc 99.1.11.1.1 http://example.com/cbc/ cubehash=ahooy sha512=m");
+   ADD(3, "cbc 99.1.11.1.1 http://example.com/cbc/ cubehash=ahooy sha512=m");
+   ADD(2, "cbc 99.1.11.1.1 http://example.com/ cubehash=ahooy");
+   ADD(2, "cbc 99.1.11.1.1 http://example.com/ cubehash=ahooy");
+   ADD(2, "cbc 99.1.11.1.1 http://example.com/ cubehash=ahooy");
+   ADD(2, "cbc 99.1.11.1.1 http://example.com/ cubehash=ahooy");
+   ADD(2, "cbc 99.1.11.1.1 http://example.com/ cubehash=ahooy");
+ 
+   /* As above but new replaces old: no two match. */
+   ADD(0, "cbc 99.1.11.1.2 http://example.com/cbc/ cubehash=ahooy sha512=m");
+   ADD(1, "cbc 99.1.11.1.2 http://example.com/cbc/ cubehash=ahooy sha512=m");
+   ADD(1, "cbc 99.1.11.1.2 http://example.com/cbc/x cubehash=ahooy sha512=m");
+   ADD(2, "cbc 99.1.11.1.2 http://example.com/cbc/ cubehash=ahooy sha512=m");
+   ADD(2, "cbc 99.1.11.1.2 http://example.com/ cubehash=ahooy");
+   ADD(2, "cbc 99.1.11.1.2 http://example.com/ cubehash=ahooy");
+   ADD(2, "cbc 99.1.11.1.2 http://example.com/ cubehash=ahooy");
+   ADD(2, "cbc 99.1.11.1.2 http://example.com/ cubehash=ahooy");
+   ADD(2, "cbc 99.1.11.1.2 http://example.com/ cubehash=ahooy");
+ 
+ 
+   res = compute_consensus_package_lines(votes);
+   tt_assert(res);
+   tt_str_op(res, ==,
+     "package cbc 99.1.11.1.1 http://example.com/cbc/ cubehash=ahooy sha512=m\n"
+     "package clownshoes 22alpha3 http://quumble.example.com/ blake2=fooz\n"
+     "package clownshoes 22alpha4 http://quumble.example.cam/ blake2=fooa\n"
+     "package element 0.66.1 http://quux.example.com/ sha256=abcdef\n"
+     "package mystic 99y http://foobar.example.com/ sha256=blahblah\n"
+             );
+ 
+ #undef ADD
+ #undef BAD
+ #undef GOOD
+  done:
+   SMARTLIST_FOREACH(votes, networkstatus_t *, ns,
+                     { smartlist_free(ns->package_lines); tor_free(ns); });
+   tor_free(res);
+ }
+ 
  #define DIR_LEGACY(name)                                                   \
    { #name, test_dir_ ## name , TT_FORK, NULL, NULL }
  
@@@ -2981,8 -3102,7 +3127,9 @@@ struct testcase_t dir_tests[] = 
    DIR_LEGACY(clip_unmeasured_bw_kb_alt),
    DIR(fmt_control_ns, 0),
    DIR(http_handling, 0),
 +  DIR(purpose_needs_anonymity, 0),
 +  DIR(fetch_type, 0),
+   DIR(packages, 0),
    END_OF_TESTCASES
  };
  

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