Browse Source

Use an autobool for UseBridges_

Nick Mathewson 14 years ago
parent
commit
14c0251d95
2 changed files with 9 additions and 13 deletions
  1. 3 8
      src/or/config.c
  2. 6 5
      src/or/or.h

+ 3 - 8
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 &&

+ 6 - 5
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