diff --git a/changes/feature18329 b/changes/feature18329 new file mode 100644 index 0000000000..7fdb659e82 --- /dev/null +++ b/changes/feature18329 @@ -0,0 +1,6 @@ + o Minor features: + - Bridge relays can now set the BridgeDistribution config option to + add a "bridge-distribution-request" line to their bridge descriptor, + which tells BridgeDB how they'd like their bridge address to be + given out. Implements tickets 18329. + diff --git a/doc/tor.1.txt b/doc/tor.1.txt index f1068cedc6..7da5ba3fe1 100644 --- a/doc/tor.1.txt +++ b/doc/tor.1.txt @@ -1647,6 +1647,12 @@ is non-zero): server descriptor to the bridge database, rather than to the public directory authorities. +[[BridgeDistribution]] **BridgeDistribution** __string__:: + If set along with BridgeRelay, Tor will include a new line in its + bridge descriptor which indicates to the BridgeDB service how it + would like its bridge address to be given out. Set it to "none" if + you want BridgeDB to avoid distributing your bridge address. + [[ContactInfo]] **ContactInfo** __email_address__:: Administrative contact information for this relay or bridge. This line can be used to contact you if your relay or bridge is misconfigured or diff --git a/src/or/config.c b/src/or/config.c index 08cc5cdf57..1bdfdf4846 100644 --- a/src/or/config.c +++ b/src/or/config.c @@ -182,6 +182,7 @@ static config_var_t option_vars_[] = { V(BridgePassword, STRING, NULL), V(BridgeRecordUsageByCountry, BOOL, "1"), V(BridgeRelay, BOOL, "0"), + V(BridgeDistribution, STRING, NULL), V(CellStatistics, BOOL, "0"), V(LearnCircuitBuildTimeout, BOOL, "1"), V(CircuitBuildTimeout, INTERVAL, "0"), @@ -3346,6 +3347,10 @@ options_validate(or_options_t *old_options, or_options_t *options, options->DirPort_set = 0; } + if (options->BridgeDistribution && !options->BridgeRelay) { + REJECT("You have set BridgeDistribution, yet you didn't set BridgeRelay!"); + } + if (options->MinUptimeHidServDirectoryV2 < 0) { log_warn(LD_CONFIG, "MinUptimeHidServDirectoryV2 option must be at " "least 0 seconds. Changing to 0."); @@ -4497,6 +4502,8 @@ options_transition_affects_descriptor(const or_options_t *old_options, get_effective_bwburst(old_options) != get_effective_bwburst(new_options) || !opt_streq(old_options->ContactInfo, new_options->ContactInfo) || + !opt_streq(old_options->BridgeDistribution, + new_options->BridgeDistribution) || !opt_streq(old_options->MyFamily, new_options->MyFamily) || !opt_streq(old_options->AccountingStart, new_options->AccountingStart) || old_options->AccountingMax != new_options->AccountingMax || diff --git a/src/or/or.h b/src/or/or.h index 33fe8b96c4..3d61cfa051 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -3638,6 +3638,10 @@ typedef struct { int BridgeAuthoritativeDir; /**< Boolean: is this an authoritative directory * that aggregates bridge descriptors? */ + /** If set on a bridge relay, it will include this value on a new + * "bridge-distribution-request" line in its bridge descriptor. */ + char *BridgeDistribution; + /** If set on a bridge authority, it will answer requests on its dirport * for bridge statuses -- but only if the requests use this password. */ char *BridgePassword; diff --git a/src/or/router.c b/src/or/router.c index 6d3a32a60c..780d0444f3 100644 --- a/src/or/router.c +++ b/src/or/router.c @@ -2867,6 +2867,14 @@ router_dump_router_to_string(routerinfo_t *router, smartlist_add_asprintf(chunks, "contact %s\n", ci); } + if (options->BridgeRelay && options->BridgeDistribution && + strlen(options->BridgeDistribution)) { + const char *bd = options->BridgeDistribution; + if (strchr(bd, '\n') || strchr(bd, '\r')) + bd = escaped(bd); + smartlist_add_asprintf(chunks, "bridge-distribution-request %s\n", bd); + } + if (router->onion_curve25519_pkey) { char kbuf[128]; base64_encode(kbuf, sizeof(kbuf),