Add new BridgeDistribution config option

Bridge relays can use it 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.
This commit is contained in:
Roger Dingledine 2016-11-13 02:39:16 -05:00 committed by Nick Mathewson
parent fcd5c3144a
commit ebab521525
5 changed files with 31 additions and 0 deletions

6
changes/feature18329 Normal file
View File

@ -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.

View File

@ -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

View File

@ -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 ||

View File

@ -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;

View File

@ -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),