[tor-commits] [tor/master] Use an autobool for UseBridges_

nickm at torproject.org nickm at torproject.org
Fri Jun 3 15:17:22 UTC 2011


commit 14c0251d95d9d86f4dba1d7d2da16661f1a87012
Author: Nick Mathewson <nickm at torproject.org>
Date:   Fri Jun 3 11:17:15 2011 -0400

    Use an autobool for UseBridges_
---
 src/or/config.c |   11 +++--------
 src/or/or.h     |   11 ++++++-----
 2 files changed, 9 insertions(+), 13 deletions(-)

diff --git a/src/or/config.c b/src/or/config.c
index 124dcb9..d663336 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -387,7 +387,7 @@ static config_var_t _option_vars[] = {
   V(TransPort,                   PORT,     "0"),
   V(TunnelDirConns,              BOOL,     "1"),
   V(UpdateBridgesFromAuthority,  BOOL,     "0"),
-  VAR("UseBridges",              STRING,   UseBridges_, "auto"),
+  VAR("UseBridges",              AUTOBOOL, UseBridges_, "auto"),
   V(UseEntryGuards,              BOOL,     "1"),
   V(UseMicrodescriptors,         AUTOBOOL, "0"),
   V(User,                        STRING,   NULL),
@@ -3308,17 +3308,12 @@ options_validate(or_options_t *old_options, or_options_t *options,
            "of the Internet, so they must not set Reachable*Addresses "
            "or FascistFirewall.");
 
-  /* XXX023 use autobool instead. */
-  if (!strcmp(options->UseBridges_, "auto")) {
+  if (options->UseBridges_ == -1) {
     options->UseBridges = (options->Bridges &&
                            !server_mode(options) &&
                            !options->EntryNodes);
-  } else if (!strcmp(options->UseBridges_, "0")) {
-    options->UseBridges = 0;
-  } else if (!strcmp(options->UseBridges_, "1")) {
-    options->UseBridges = 1;
   } else {
-    REJECT("UseBridges must be 0, 1, or auto");
+    options->UseBridges = options->UseBridges_;
   }
 
   if (options->UseBridges &&
diff --git a/src/or/or.h b/src/or/or.h
index 1b4cdb8..b4000ad 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -2646,11 +2646,12 @@ typedef struct {
    * when doing so. */
   char *BridgePassword;
 
-  /** Whether we should start all circuits with a bridge. "1" means strictly
-   * yes, "0" means strictly no, and "auto" means that we do iff any bridges
-   * are configured, we are not running a server and have not specified a list
-   * of entry nodes. */
-  char *UseBridges_;
+  /** Whether we should start all circuits with a bridge. This is an
+   * "autobool": 1 means strictly yes, 0 means strictly no, and -1 means that
+   * we do iff any bridges are configured, we are not running a server and
+   * have not specified a list of entry nodes.   Don't use this value directly;
+   * use <b>UseBridges</b> instead. */
+  int UseBridges_;
   /** Effective value of UseBridges. Will be set equally for UseBridges set to
    * 1 or 0, but for 'auto' it will be set to 1 iff any bridges are
    * configured, we are not running a server and have not specified a list of



More information about the tor-commits mailing list