[tor-commits] [tor/release-0.3.2] Add new BridgeDistribution config option

nickm at torproject.org nickm at torproject.org
Tue Oct 24 23:37:21 UTC 2017


commit ebab5215252f9fa810ae091c335c5ae6e619faaf
Author: Roger Dingledine <arma at torproject.org>
Date:   Sun Nov 13 02:39:16 2016 -0500

    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.
---
 changes/feature18329 | 6 ++++++
 doc/tor.1.txt        | 6 ++++++
 src/or/config.c      | 7 +++++++
 src/or/or.h          | 4 ++++
 src/or/router.c      | 8 ++++++++
 5 files changed, 31 insertions(+)

diff --git a/changes/feature18329 b/changes/feature18329
new file mode 100644
index 000000000..7fdb659e8
--- /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 f1068cedc..7da5ba3fe 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 08cc5cdf5..1bdfdf484 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 33fe8b96c..3d61cfa05 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 6d3a32a60..780d0444f 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),





More information about the tor-commits mailing list