]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Dirauth: generate microdescs with family-ids.
authorNick Mathewson <nickm@torproject.org>
Wed, 12 Feb 2025 19:49:35 +0000 (14:49 -0500)
committerNick Mathewson <nickm@torproject.org>
Thu, 6 Mar 2025 14:41:54 +0000 (09:41 -0500)
src/feature/dirauth/dirvote.c
src/feature/dirauth/dirvote.h
src/test/test_microdesc.c

index 42c08024339dc80624b87a3905a58bfb07507969..833d0566ba5fb0a2b5237684a31163b13ff7b8e4 100644 (file)
@@ -3900,6 +3900,13 @@ dirvote_create_microdescriptor(const routerinfo_t *ri, int consensus_method)
     tor_free(canonical_family);
   }
 
+  if (consensus_method >= MIN_METHOD_FOR_FAMILY_IDS &&
+      ri->family_ids && smartlist_len(ri->family_ids)) {
+    char *family_ids = smartlist_join_strings(ri->family_ids, " ", 0, NULL);
+    smartlist_add_asprintf(chunks, "family-ids %s\n", family_ids);
+    tor_free(family_ids);
+  }
+
   if (summary && strcmp(summary, "reject 1-65535"))
     smartlist_add_asprintf(chunks, "p %s\n", summary);
 
@@ -3995,6 +4002,8 @@ static const struct consensus_method_range_t {
   int high;
 } microdesc_consensus_methods[] = {
   {MIN_SUPPORTED_CONSENSUS_METHOD,
+   MIN_METHOD_FOR_FAMILY_IDS - 1},
+  {MIN_METHOD_FOR_FAMILY_IDS,
    MAX_SUPPORTED_CONSENSUS_METHOD},
   {-1, -1}
 };
index 6ac07f171a33d906428544e0226719d76e185486..6f894e9d63caa33f5c4472fe1087dad18db817a7 100644 (file)
@@ -53,7 +53,7 @@
 #define MIN_SUPPORTED_CONSENSUS_METHOD 32
 
 /** The highest consensus method that we currently support. */
-#define MAX_SUPPORTED_CONSENSUS_METHOD 34
+#define MAX_SUPPORTED_CONSENSUS_METHOD 35
 
 /**
  * Lowest consensus method for which we suppress the published time in
  **/
 #define MIN_METHOD_TO_OMIT_PACKAGE_FINGERPRINTS 34
 
+/**
+ * Lowest supported consensus method for which we include `family-ids`
+ * in microdescs.
+ */
+#define MIN_METHOD_FOR_FAMILY_IDS 35
+
 /** Default bandwidth to clip unmeasured bandwidths to using method >=
  * MIN_METHOD_TO_CLIP_UNMEASURED_BW.  (This is not a consensus method; do not
  * get confused with the above macros.) */
index 036d97692c8d868c4e996d94c91fe8ef80ee17fd..adbca0563c020424b8ae208ca1661c6bbd99a789 100644 (file)
@@ -378,6 +378,21 @@ static const char test_md2_withfamily_33[] =
   "p accept 1-65535\n"
   "id ed25519 J5lkRqyL6qW+CpN3E4RIlgJZeLgwjtmOOrjZvVhuwLQ\n";
 
+static const char test_md2_withfamilyids_35[] =
+  "onion-key\n"
+  "-----BEGIN RSA PUBLIC KEY-----\n"
+  "MIGJAoGBAMvEJ/JVNK7I38PPWhQMuCgkET/ki4WIas4tj5Kmqfb9kHqxMR+EunRD\n"
+  "83k4pel1yB7QdV+iTd/4SZOI8RpZP+BO1KnOTWfpztAU1lDGr19/PwdwcHaILpBD\n"
+  "nNzm6otk4/bKUQ0vqpOfJljtg0DfAm4uMAQ6BMFy6uEAF7+JupuPAgMBAAE=\n"
+  "-----END RSA PUBLIC KEY-----\n"
+  "ntor-onion-key FChIfm77vrWB7JsxQ+jMbN6VSSp1P0DYbw/2aqey4iA\n"
+  "family !Strange $D219590AC9513BCDEBBA9AB721007A4CC01BBAE3 othernode\n"
+  "family-ids "
+       "ed25519:YWxsIGhhcHB5IGZhbWlsaWVzIGFyZSBhbGlrZSAtTFQ "
+       "rlwe:0YHRh9Cw0YHRgtC70LjQstGL0LUg0YHQtdC80YzQuC0\n"
+  "p accept 1-65535\n"
+  "id ed25519 J5lkRqyL6qW+CpN3E4RIlgJZeLgwjtmOOrjZvVhuwLQ\n";
+
 static void
 test_md_generate(void *arg)
 {
@@ -395,6 +410,16 @@ test_md_generate(void *arg)
   md = dirvote_create_microdescriptor(ri, 33);
   tt_str_op(md->body, OP_EQ, test_md2_withfamily_33);
 
+  // Try family-ids.
+  microdesc_free(md);
+  ri->family_ids = smartlist_new();
+  smartlist_add_strdup(ri->family_ids,
+                       "ed25519:YWxsIGhhcHB5IGZhbWlsaWVzIGFyZSBhbGlrZSAtTFQ");
+  smartlist_add_strdup(ri->family_ids,
+                       "rlwe:0YHRh9Cw0YHRgtC70LjQstGL0LUg0YHQtdC80YzQuC0");
+  md = dirvote_create_microdescriptor(ri, 35);
+  tt_str_op(md->body, OP_EQ, test_md2_withfamilyids_35);
+
  done:
   microdesc_free(md);
   routerinfo_free(ri);