From: Nick Mathewson Date: Wed, 12 Feb 2025 19:49:35 +0000 (-0500) Subject: Dirauth: generate microdescs with family-ids. X-Git-Tag: tor-0.4.9.2-alpha~33^2~9 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=67a657f27450488379a668d0d8a57495e1bf511e;p=thirdparty%2Ftor.git Dirauth: generate microdescs with family-ids. --- diff --git a/src/feature/dirauth/dirvote.c b/src/feature/dirauth/dirvote.c index 42c0802433..833d0566ba 100644 --- a/src/feature/dirauth/dirvote.c +++ b/src/feature/dirauth/dirvote.c @@ -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} }; diff --git a/src/feature/dirauth/dirvote.h b/src/feature/dirauth/dirvote.h index 6ac07f171a..6f894e9d63 100644 --- a/src/feature/dirauth/dirvote.h +++ b/src/feature/dirauth/dirvote.h @@ -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 @@ -67,6 +67,12 @@ **/ #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.) */ diff --git a/src/test/test_microdesc.c b/src/test/test_microdesc.c index 036d97692c..adbca0563c 100644 --- a/src/test/test_microdesc.c +++ b/src/test/test_microdesc.c @@ -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);